Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
ferrethouse
Constraint Violating Yak Guru
352 Posts |
Posted - 2009-09-01 : 13:22:58
|
Msg 245, Level 16, State 1, Procedure GetAffectedStudentCount, Line 13Syntax error converting the varchar value 'SELECT COUNT(*) as Affected FROM Students WHERE ClientID = ' to a column of data type int.ALTER PROCEDURE [dbo].[GetAffectedStudentCount] (@WhereClause NVARCHAR(500),@ClientID int)ASBEGINDECLARE @SQL varchar(255)DECLARE @Counter intSET @SQL = 'SELECT COUNT(*) as Affected FROM Students WHERE ClientID = ' + @ClientID + ' AND ' + @WhereClauseCREATE TABLE #myResults( Col1 INT)INSERT INTO #myResults(Col1)EXEC (@SQL)DECLARE my_cursor CURSORFOR SELECT Col1 FROM #myResultsOPEN my_cursorFETCH NEXT FROM my_cursor INTO @CounterRETURN @CounterEND |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2009-09-01 : 14:54:52
|
| I'm guessing that clientid in the students table is not integer. Also, what are you trying to accomplish with this query? There may be a better way to write it that avoids cursors and dynamic sql. Jim |
 |
|
|
|
|
|