can anyone tell me why the following stored procedure errors out?
Create Procedure StandEdit_ErrorCheck
@TableName VarChar(100)
AS
Declare @SQL VarChar(1000)
--Check for Duplicate Standids
SELECT @SQL = 'SELECT standid FROM '
SELECT @SQL = @SQL + @TableName + 'GROUP BY standid '
--GROUP BY standid
--HAVING count(*) > 1
Exec ( @SQL)
GO
StandEdit_ErrorCheck klstandedits
Server: Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'BY'.
Create Procedure StandEdit_ErrorCheck
@TableName VarChar(100)
AS
Declare @SQL VarChar(1000)
--Check for Duplicate Standids
SELECT @SQL = 'SELECT standid FROM '
SELECT @SQL = @SQL + @TableName + 'GROUP BY standid '
--GROUP BY standid
--HAVING count(*) > 1
Exec ( @SQL)
GO
StandEdit_ErrorCheck klstandedits
Server: Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'BY'.