Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How Below SP execute

Author  Topic 

PuneetJain
Starting Member

3 Posts

Posted - 2008-09-01 : 12:34:25
Hi,

Can anybody explain the below SP line by Line

CREATE PROC GO @GO int=NULL AS SELECT @GO
GO
GO;
GO 3
GO
EXECUTE('GO 1')
GO 3
GO
DROP PROC GO
GO

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-09-01 : 13:15:41
your syntax is wrong.

Why not just read a book. In MSSQL press F1 to get to books online
Go to Top of Page

PuneetJain
Starting Member

3 Posts

Posted - 2008-09-01 : 13:20:38
quote:
Originally posted by afrika

your syntax is wrong.

Why not just read a book. In MSSQL press F1 to get to books online



Hi,

i have checked, synatx is absolutely fine.

i am getting output.

please run this in sql server.

Thanks
Puneet

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-09-02 : 02:57:26
http://sqlblogcasts.com/blogs/madhivanan/archive/2008/08/06/another-use-of-go-command-in-sql-server-2005.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

PuneetJain
Starting Member

3 Posts

Posted - 2008-09-02 : 11:12:50
this has cleared me alot, just a small question

whats the difference between GO and GO;


quote:
Originally posted by madhivanan

http://sqlblogcasts.com/blogs/madhivanan/archive/2008/08/06/another-use-of-go-command-in-sql-server-2005.aspx

Madhivanan

Failing to plan is Planning to fail

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-09-04 : 10:04:01
quote:
Originally posted by PuneetJain

this has cleared me alot, just a small question

whats the difference between GO and GO;


quote:
Originally posted by madhivanan

http://sqlblogcasts.com/blogs/madhivanan/archive/2008/08/06/another-use-of-go-command-in-sql-server-2005.aspx

Madhivanan

Failing to plan is Planning to fail




Well. As you used GO as the procedure name, to execute it for 3 times, you need to use semicolon. GO; means it is a procedure name and not batch seperator GO

Run this and see the difference

CREATE PROC GO @GO int=NULL AS SELECT @GO
GO
GO
GO 3
GO
EXECUTE('GO 1')
GO 3
GO
DROP PROC GO
GO


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-09-04 : 10:11:14
Also your first example can be rewritten as

CREATE PROC GO @GO int=NULL AS SELECT @GO
GO
[GO]
GO 3
GO
EXECUTE('GO 1')
GO 3
GO
DROP PROC GO
GO

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -