Re: Return Counts Different In Similar SQL Statements
From: Vishal Parkar (REMOVE_THIS_vgparkar_at_yahoo.co.in)
Date: 03/19/04
- Previous message: Bruce: "Return Counts Different In Similar SQL Statements"
- In reply to: Bruce: "Return Counts Different In Similar SQL Statements"
- Next in thread: Bruce Rose: "Re: Return Counts Different In Similar SQL Statements"
- Reply: Bruce Rose: "Re: Return Counts Different In Similar SQL Statements"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 20 Mar 2004 01:20:30 +0530
hi bruce,
select count1 = count(*) FROM ##junk
WHERE (LastName = @sLastName )
Above query will look for match for the string ''smith''(ie anything within the single quotes
will be compared, which does not exists in the table. you need to add '' (2 single quotes) in
the string to use it in the dynamic sql(to get the effect of single quote). so that your
dynamically created string can be formed as
select count2 = count(*) FROM ##junk WHERE (LastName = 'smith')
Use print statement to see what is the dynamically generated string looks like:
Ex:
print @s
in short 2 single quotes gives you the effect of 1 single quote while dynamically running
query, this is not the case while running the normal query and your select statement will be
run as follows, which will obviously return 0.
select count1 = count(*) FROM ##junk
WHERE (LastName = ''smith'' )
-- Vishal Parkar vgparkar@yahoo.co.in
- Previous message: Bruce: "Return Counts Different In Similar SQL Statements"
- In reply to: Bruce: "Return Counts Different In Similar SQL Statements"
- Next in thread: Bruce Rose: "Re: Return Counts Different In Similar SQL Statements"
- Reply: Bruce Rose: "Re: Return Counts Different In Similar SQL Statements"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|