Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple commands on one line in SQL Server 2005

I would like to execute multiple statements on one line in SQL Server 2005. How do I do the following on a single line:


use master
go
sp_spaceused mytable

When I try use master; go; sp_spaceused mytable I get Incorrect syntax near 'go'.

When I try use master go sp_spaceused mytable I get Incorrect syntax near 'go'.

like image 773
PP. Avatar asked Feb 15 '10 09:02

PP.


2 Answers

use master; sp_spaceused mytable;

should suffice. GO simply signals the end of a batch of Transact-SQL statements to the SQL Server utilities.

like image 186
davek Avatar answered Sep 21 '22 07:09

davek


You don't need GO. Just use ;

like image 30
Alex Shirshov Avatar answered Sep 23 '22 07:09

Alex Shirshov