SQL Tips by Namwar Rizvi

May 8, 2007

Retrieving DDL of SQL Server objects

Filed under: Object Search,Query,TSQL — namwar @ 10:18 PM

Following is just a quickest and simplest way to retrieve DDL or the SQL required to create a database object:

Select
OBJECT_Definition(Object_ID(
dbo.uspGetBillOfMaterials’))

Just replace “dbo.uspGetBillOfMaterials” with your required object name like table, stored procedure etc.

Advertisements

2 Comments »

  1. Doesn’t work on SQL Server 7 or 2000 though …

    Comment by Anonymous — May 9, 2007 @ 1:59 PM | Reply

  2. Yes, you are right. It does not work on SQL Server 7 or 2000. For SQL Server 2000 and 2005 both, you can use
    sp_helptext.

    Following is the link from msdn:

    https://www.blogger.com/comment.g?blogID=7249105875140794311&postID=70880107877237914

    Comment by Namwar — May 9, 2007 @ 4:02 PM | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: