Hi NevadaVegas,
If there is no record meets
WHERE PlayerID= ' + STR(@@nPlayerID)
in table “@tblName”, we will get @iRowCount value as '0'. I tested the following codes with AdventureWorks2012 database, and found both of “sp_executesql” and “exec” commands will return the same @@RowCount value. You can refer to the following codes:
use AdventureWorks2012; go -- sp_executesql declare @strsql nvarchar(1000), @ncount int set @strsql = 'select * from person.Person' exec sp_executesql @strsql set @ncount = @@ROWCOUNT select @nCount -- result : 19972 --exec declare @strsql varchar(1000), @ncount int set @strsql = 'select * from person.Person' exec(@strsql) set @ncount = @@ROWCOUNT select @nCount -- result : 19972 -- sp_executesql, update declare @strsql nvarchar(1000), @ncount int set @strsql = 'update person.Person set FirstName = ''KenOLD'' where [BusinessEntityID] = 1' exec sp_executesql @strsql set @ncount = @@ROWCOUNT select @nCount -- 1 --exec, update declare @strsql varchar(1000), @ncount int set @strsql = 'update person.Person set FirstName = ''Ken'' where [BusinessEntityID] = 1' exec(@strsql) set @ncount = @@ROWCOUNT select @nCount -- 1
Allen Li
TechNet Community Support
Image may be NSFW.
Clik here to view.