Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Data Management

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Your profile

    Search

    XML Feeds

    Google Ads

    « How to import a bunch of XML files from a directory in T-SQLComparing the Chicago Highway System to your Disaster/Recovery Plans »
    comments

    This question came up recently so I decided to blog about it
    If you have your stored procedures in source control and you want to see if they are the same as the one on the server, all you need to do is script out the procs and do a diff right?

    Let's see what happens, create this proc

    1. Create procedure prTest
    2. as
    3. set nocount on
    4. if exists (select 1 from sys.procedures where name = 'prTest')
    5. print 'yes'
    6. else
    7. print'no'

    Now script it out, you do this by finding the proc under your database-->programmability-->stored procedures. Right click on the proc, select script procedure as and then choose create to and pick a new window
    Your procedure will look like this

    1. /****** Object:StoredProcedure [dbo].[prTest] Script Date: 04/28/2009 10:07:19 ******/
    2. SET ANSI_NULLS ON
    3. GO
    4. SET QUOTED_IDENTIFIER ON
    5. GO
    6. Create procedure [dbo].[prTest]
    7. as
    8. set nocount on
    9. if exists (select 1 from sys.procedures where name = 'prTest')
    10. print 'yes'
    11. else
    12. print'no'

    Do you see the problem? The first line has a comment and this will make your proc unique every time you script it out. Fortunately you can disable this by unchecking include descriptive headers. The process to do this is different for SQL Server 2000, 2005 and 2008

    For SQL Server 2000 it is under the formatting tab in the Generate SQL Script object (see image below)


    Scripting in SQL Server 2000


    For SQL Server 2005 it is under Tools-->Options-->Scripting(see image below)

    Scripting in SQL Server 2005


    For SQL Server 2008 it is under Tools-->Options-->SQL Server Object Explorer-->Scripting(see image below)

    Scripting in SQL Server 2008

    About the Author

    User bio imageDenis has been working with SQL Server since version 6.5. Although he worked as an ASP/JSP/ColdFusion developer before the dot com bust, he has been working exclusively as a database developer/architect since 2002. In addition to English, Denis is also fluent in Croatian and Dutch, but he can curse in many other languages and dialects (just ask the SQL optimizer) He lives in Princeton, NJ with his wife and three kids.
    Social SitingsTwitterFacebookLinkedInHomePageFlickrLTD RSS Feed
    1297 views
    Instapaper

    2 comments

    Comment from: chopstik [Member]
    ****-
    chopstik Interesting... But I may be missing why this would be an issue. Can you elaborate?
    04/28/09 @ 16:53
    Comment from: SQLDenis [Member] Email
    *****
    SQLDenis chopstik ,if you script out the proc store it in source control, script out the same proc 5 minutes later also store it in source control and then you do a diff they will look different because the first comment will have a different timestamp on it

    /****** Object:StoredProcedure [dbo].[prTest] Script Date: 04/28/2009 10:07:19 ******/

    /****** Object:StoredProcedure [dbo].[prTest] Script Date: 04/28/2009 10:12:19 ******/
    04/29/09 @ 06:48

    Leave a comment


    Your email address will not be revealed on this site.

    Your URL will be displayed.
    (Line breaks become <br />)
    (Name, email & website)
    (Allow users to contact you through a message form (your email will not be revealed.)