Search code examples
sqlsql-serverstored-proceduresprocedure

No output when stored procedure is executed


No output when stored procedure is executed. The select statement works when I create a new query , but does not return any values when calling the store procedure within my Web app.


Solution

  • You want a dynamic sql. try this.

    Declare @strSQL nvarchar(2000)
    set @strSQL = 'SELECT * FROM investor WHERE ' + @search_by + ' = ''' + @col + ''''
    execute sp_executesql @strSQL