I want to create a query that returns the results of an ID but I'm passing the table name as a parameter so I'm using code like:
I can't seem to figure out how to get the results of my query into @temp variable. What's the T-SQL code to do this?
Thanks,
Rewdee
Code:
CREATE PROCEDURE [dbo].[SP_GET_NEXT_LARGE_ID]
(
@TableName varchar(50),
@ID CHAR(25) OUTPUT,
@NUMRET INTEGER OUTPUT
)
AS
DECLARE
@SQL_STATEMENT varchar(255),
@temp int
BEGIN
Set @ID = '0000000000000000000000000'
Set @NumRet = 0
Set @SQL_STATEMENT = 'SELECT MAX(id) FROM ' + @TableName + ' WHERE (id LIKE "000%")'
exec @SQL_STATEMENT
@temp= exec @SQL_STATEMENT
Thanks,
Rewdee