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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Parameter as a column name

Author  Topic 

nimmika
Starting Member

1 Post

Posted - 2009-02-13 : 02:21:50

I want to use a parameter as a column name in my select list. For that I have used following sql statements in a stored procedure.

DECLARE @strSQL varchar(max)

set @strSQL = 'SELECT ' + @order + ' AS ' +@order+ ' FROM AircraftReplenishmentsTxn WHERE AircraftSerialNo ='''+@AircraftSerialNo+''' ' +'AND TransactionType ='''+@TransactionType+''' '

EXEC (@strSQL)

when i execute sp i'm getting several records.But when i bind it to SQL report it shows only the last record. Is there a way to solve the problem without using EXEC.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-13 : 09:51:33
didnt get that. what do you mean its gets last record? are you trying to store value somewhere?
Go to Top of Page
   

- Advertisement -