Monday, December 26, 2011

GO Command in SQL Server

GO Command indicates the batch ending signal of Transact-SQL statements to the SQL Server utilities.

Syntax:

GO [count]
 
Is a positive integer. The batch preceding GO will execute the specified number of times.
 
GO is not a Transact-SQL statement, it is a command recognized by the sqlcmd and osql utilities and SQL Server Management Studio Code editor.
 
Here, i'm giving a tip using GO command to insert same data multiple times wthout a loop.
 
CREATE TABLE TestTbl
(
    id INT IDENTITY(1,1),
    name VARCHAR(255),
    address VARCHAR(255)
)

SELECT * FROM Northwind..TestTbl
 

 
 
 
INSERT INTO Northwind..TestTbl VALUES ('johnson','Street view')
GO 5
 









SELECT * FROM Northwind..TestTbl 
 
 

No comments:

Post a Comment