Thursday 28 July 2016

Go Statement

/*Go - this command will send the current batch of query to no of times to sql instance*/
drop table #Test
create table #Test
(
sno int identity(1,1),
sd char(4)
)

go
insert into #Test select 'ss'
go 10

/*the above statement will execute 10 times*/

select * from #Test

/**************************/

/*please Check the differences of all below 3 set of statements: which one is printing more than 1 times!*/

print 'hi'
print 'hello'
go 5

/**/

print 'hi'
go 5
print 'hello'

/**/

go 5
print 'hi'
print 'hello'


/**********************/

declare @msg char(10)
set @msg= 'hi'

select @msg  as 'before go'
go
print @msg  as 'after go'

/*please Check the scope of the parameter declaration after sending GO commend*/

/**************/

No comments:

Post a Comment