RE: Different Row Counts From Two Virtually Identical Queries
From: Xavier Lazard (anonymous_at_discussions.microsoft.com)
Date: 03/19/04
- Next message: Dennis Forbes: "Bookmark lookup cost factors (SQL Server 7.0)"
- Previous message: Dragan BAbovic: "RE: Update lock seems to hang"
- In reply to: Bruce Rose: "Different Row Counts From Two Virtually Identical Queries"
- Next in thread: Xavier Lazard: "RE: Different Row Counts From Two Virtually Identical Queries"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 19 Mar 2004 08:56:12 -0800
The two queries are not comparing the same thing due to the extra quotation marks:
see below
create table ##junk ( LastName nvarchar(100) )
go
insert into ##junk values ('smith')
go
declare @s varchar(4000)
declare @sLastName nvarchar(100)
select @sLastName = 'smith'
select count1 = count(*) FROM ##junk
WHERE (LastName = @sLastName )
select @sLastName = '''smith'''
select @s =
'select count2 = count(*) FROM ##junk ' +
'WHERE (LastName = ' + @sLastName + ') '
exec (@s)
drop table ##junk
go
- Next message: Dennis Forbes: "Bookmark lookup cost factors (SQL Server 7.0)"
- Previous message: Dragan BAbovic: "RE: Update lock seems to hang"
- In reply to: Bruce Rose: "Different Row Counts From Two Virtually Identical Queries"
- Next in thread: Xavier Lazard: "RE: Different Row Counts From Two Virtually Identical Queries"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|