Wednesday 17 July 2013

T-SQL GO Statement

It is a batch terminator
this will break
declare @i int
set @i =5

declare @i int
set @i =6

Select @i
Msg 134, Level 15, State 1, Line 5 The variable name '@i' has already been declared. Variable names must be unique within a query batch or stored procedure.
this will work
declare @i int
set @i =5

go
declare @i int
set @i =6

Select @i

No comments:

Post a Comment

C# LINQ Joins With SQL

There are  Different Types of SQL Joins  which are used to query data from more than one database tables. In this article, you will learn a...