question

Vishal avatar image
Vishal asked

Object Name Length Restriction

Hi, I have a requirement to restrict user to create objects (Table, Function, Sroted Procedure etc) to specified length. We are working on project which will be on both SQL Server and Oracle and there is restriction in Oracle that an object name cannot exceed length of 30 characters and same as Column names for a table. Please help me in this regard. Thanks.
create
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Cyborg avatar image
Cyborg answered
IF you are using SQL Server 2008 then, Policy based management will be doing the job. If your sql server is 2005 or below then probably you may need to create Database Triggers or DDL Triggers to check the length of the Database objects name that the users are creating.
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Vishal avatar image Vishal commented ·
Thanks. DDL Trigger worked, I was struggling to find out the object name when creating the object. Now I got that. Thanks.
0 Likes 0 ·
Fatherjack avatar image
Fatherjack answered
I would go with the DDL option mentioned by Cyborg as that will go with the database, to other servers etc. Its not too tricky to implement and you can get it to provide a meaningful error message to the user so that they can make the necessary change. Here are some resources, MSDN/BoL first [ http://msdn.microsoft.com/en-us/library/ms186406.aspx][1] and [ http://www.sqlbook.com/SQL-Server/DDL-Triggers-in-SQL-Server-34.aspx][2]. [1]: http://msdn.microsoft.com/en-us/library/ms186406.aspx [2]: http://www.sqlbook.com/SQL-Server/DDL-Triggers-in-SQL-Server-34.aspx
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Vishal avatar image Vishal commented ·
Thanks. DDL Trigger worked, I was struggling to find out the object name when creating the object. Now I got that. The link really helped me. Thanks.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.