What is the difference using the single or double quotes in a stored
procedure ?
Ex1: where username = @.username
AND status = "D" -- or 'D'
Ex2: if @.stringtype = "D" -- or 'D'
Select ...............
Thanks.
See "SET QUOTED_IDENTIFIER" in BOL.
Example:
use northwind
go
set quoted_identifier off
go
select 1
where
"1111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111 11111111111111111111111111111" != '1'
go
set quoted_identifier on
go
select 1
where
"1111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111 11111111111111111111111111111" != '1'
go
The first "select" statement will return '1', but the second one will give
an error because sql server will consider the string as an identifier.
AMB
"DXC" wrote:
> What is the difference using the single or double quotes in a stored
> procedure ?
> Ex1: where username = @.username
> AND status = "D" -- or 'D'
> Ex2: if @.stringtype = "D" -- or 'D'
> Select ...............
>
> Thanks.
|||Thanks...........
"Alejandro Mesa" wrote:
[vbcol=seagreen]
> See "SET QUOTED_IDENTIFIER" in BOL.
> Example:
> use northwind
> go
> set quoted_identifier off
> go
> select 1
> where
> "1111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111 11111111111111111111111111111" != '1'
> go
> set quoted_identifier on
> go
> select 1
> where
> "1111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111 11111111111111111111111111111" != '1'
> go
>
> The first "select" statement will return '1', but the second one will give
> an error because sql server will consider the string as an identifier.
>
> AMB
> "DXC" wrote:
No comments:
Post a Comment