May 21, 2004 at 4:39 am
I have the following procedure. When i execute it it's giving me syntax error near '='. When I remove @count it works. So what's wrong with the syntax like this and how to solve it?? create PROCEDURE [dbo].[USP_GetFileCount] @tableName nvarchar(50),@colName nvarchar(50), @recordID int, @count int output AS exec( 'select ' + @count + ' = count(*) from '+ @tableName + 'where ' + @colName + ' = ' + @recordID) |
May 21, 2004 at 4:58 am
You have to convert @Count to VARCHAR or CHAR
--Jeff Moden
May 21, 2004 at 6:01 am
Try
declare @sql nvarchar(100)
set @sql = 'select @count = count(*) from ' +
@tableName + ' where ' + @colName + ' = ' + CAST(@recordID as varchar)
exec sp_executesql @sql,N'@count int output',@count output
select @count
Far away is close at hand in the images of elsewhere.
Anon.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply