我想在SQL Server 2005中的一行上执行多条语句。如何在一行上执行以下操作:
use master
go
sp_spaceused mytable
[当我尝试use master; go; sp_spaceused mytable
时,我会得到Incorrect syntax near 'go'
。
[当我尝试use master go sp_spaceused mytable
时,我会得到Incorrect syntax near 'go'
。
use master; sp_spaceused mytable;
应足够。 GO
只是signals the end of a batch of Transact-SQL statements to the SQL Server utilities。
您不需要GO
。只需使用;
到目前为止提供的答案是不正确的。如果行必须在单独的批处理中,则不能将行与分号合并。试试这个:
DECLARE @x int; DECLARE @x int;