If you want to write the stored procedure, you want to get the value of 'Select Dvalue from' @tablename, use it alter procedure sp_getvalue @sqlstr varchar (2000), @output varchar (50) Output, @ output1 int output, @Type int as / ******************* Change Date: 2003-04-03 Modifier: wu Remarks: Incoming a SQL statement, getting the first Variable content, returning 0 in the form of strings, represents numbers 1 represent strings ****************** / DECLARE @tmpsqlstr varchar (4000) set @tmpsqlstr = ' declare mycursor cursor for ' @sqlstr exec (@tmpsqlstr) open mycursorif @type = 0 fetch next from mycursor into @outputelse fetch next from mycursor into @ output1 close mycursor deallocate mycursor