Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««123

T-SQL Expand / Collapse
Author
Message
Posted Monday, November 17, 2008 8:20 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 12:53 PM
Points: 2,392, Visits: 2,786
I got this right for the wrong reason. I didn't know that the lack of the GO was what added the second insert to the stored procedure. But the test insert just looked like part of the whole procedure after the procedure code (perhaps the lack of even a line break before the test insert tipped off my unconscious :)), so I figured the test insert will run every time the procedure runs.

Tricky question but a good lesson. I will definitely be more careful about creating procedures in the future.

Thanks!
webrunner


-------------------
"Operator! Give me the number for 911!" - Homer Simpson

"A SQL query walks into a bar and sees two tables. He walks up to them and says 'Can I join you?'"
Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html
Post #603695
Posted Monday, November 17, 2008 10:31 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, June 28, 2010 7:57 PM
Points: 4, Visits: 8
slange (11/14/2008)
I fell victim to a similair script at one point. As a result I now make it my standard habit that after the declaration of the sp i wrap the entire body in a begin end.

declare myProc() as
begin

end

Once you stub in the solid open and closing it is very easy to fill in the body and even more difficult to accidentally leave something inside the proc.

YES, a good habit !
Post #604097
Posted Wednesday, January 16, 2013 2:16 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Monday, October 20, 2014 4:54 AM
Points: 1,921, Visits: 2,345
really nice question.....


_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1407688
« Prev Topic | Next Topic »

Add to briefcase «««123

Permissions Expand / Collapse