Create Sample Table with Command GO [count] (T-SQL)


By adding a number (n) after GO, the batch will exexute n times. 

Here is a T-SQL snippet to create a sample table with 50 records in it:

<pre>

CREATE TABLE myNumTable   (id int identity(1,1),c1 datetime default getdate(), c2 varchar(50) default ‘test’)

GO

INSERT INTO myNumTable DEFAULT  
VALUES GO 50  

 

SELECT * FROM myNumTable 
</pre>

 

The GO is the signal to start a batch of T-SQL statement but itself is not a T-SQL statement. It is recognized by the sqlcmd and osql utilities.

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s