iangregson1
asked on
sql server management studio questions with regards to attaching and using GO?
Hi there,
I have been using the sql server management studio (express) and i would like to know what the difference is of creating a db in the studio or creating in VS 2005... it appears that one is attached and the other isn't?
What are the pros and cons of the 2 different ways?
Also when i write queries etc in sqlcmd.. i use GO to execute the command/s ...but in SQL Management studio is there any point to GO?? As you click the EXECUTE button on the toolbar to execute the script which i assume executes ALL of the script not just the current line
If anybody can confirm anything i would be really grateful..
thansk
I have been using the sql server management studio (express) and i would like to know what the difference is of creating a db in the studio or creating in VS 2005... it appears that one is attached and the other isn't?
What are the pros and cons of the 2 different ways?
Also when i write queries etc in sqlcmd.. i use GO to execute the command/s ...but in SQL Management studio is there any point to GO?? As you click the EXECUTE button on the toolbar to execute the script which i assume executes ALL of the script not just the current line
If anybody can confirm anything i would be really grateful..
thansk
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi thanks for the reply, but it is totally valid to do the following in SSMS
command
GO
command
GO
etc
it sqlcmd GO executes the statements.. but in SSMS when you click execute it seems that ALL statements are executed weather or not the GO is there??
command
GO
command
GO
etc
it sqlcmd GO executes the statements.. but in SSMS when you click execute it seems that ALL statements are executed weather or not the GO is there??
ASKER
Ermm maybe i didn't explain myself correctly, ok is SSMS .. if i put this into a query window .. i get 2 resultsets back... but i didn't use GO?? So what is the difference? I just click the EXECUTE .. and all 3 commands are evaluated and run...
USE test;
SELECT * FROM dbo.Table_1 WHERE test='1';
SELECT * FROM dbo.Table_1 WHERE test='2';
USE test;
SELECT * FROM dbo.Table_1 WHERE test='1';
SELECT * FROM dbo.Table_1 WHERE test='2';
ASKER
I even tried this... and the execute sure enough EXECUTES all commands.. with or without a GO
USE test;
SELECT * FROM dbo.Table_1 WHERE test='1';
SELECT * FROM dbo.Table_1 WHERE test='2';
GO
SELECT * FROM dbo.Table_1 WHERE test='4';
USE test;
SELECT * FROM dbo.Table_1 WHERE test='1';
SELECT * FROM dbo.Table_1 WHERE test='2';
GO
SELECT * FROM dbo.Table_1 WHERE test='4';
ASKER
Oh i think i found, can anyone confirm it for me..
If you make 4 statements into one batch like this --
statement1; statement2; statement3; statement4 GO
....and statement4 fails with an error, the affected objects are
restored to the way they were before statement1. so if 4 FAILS then ALL fails!
If you make them 4 separate batches like this --
statement1 GO statement2 GO statement3 GO statement4 GO
.... and statement4 fails with an error, the objects are restored to
the way they were after statement 3.
So i presume a long script without using GO then if something failed ... they would all get returned to how they were before??? Pretty much like putting a GO at the end of a script...??
Any advise really appreciated
If you make 4 statements into one batch like this --
statement1; statement2; statement3; statement4 GO
....and statement4 fails with an error, the affected objects are
restored to the way they were before statement1. so if 4 FAILS then ALL fails!
If you make them 4 separate batches like this --
statement1 GO statement2 GO statement3 GO statement4 GO
.... and statement4 fails with an error, the objects are restored to
the way they were after statement 3.
So i presume a long script without using GO then if something failed ... they would all get returned to how they were before??? Pretty much like putting a GO at the end of a script...??
Any advise really appreciated
http://thinkwrap.wordpress.com/2007/05/11/differences-between-visual-studio-and-ssms/