开发者

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; g开发者_运维知识库o; sp_spaceused mytable I get Incorrect syntax near 'go'.

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


use master; sp_spaceused mytable;

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


You don't need GO. Just use ;


The answers provided thus far are incorrect. It does not work to combine lines with a semi-colon if the lines must be in a separate batch. Try this one:

DECLARE @x int; DECLARE @x int;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜