Stored Procedure column Name problem
I have a table with numbers for columns like so :
columns --> category title [1] [2] [3]
asp code .5 .3 .7
i am pulling data from another table and using that data as a lookup on this
table. for instance.
Select table1.number
select [table1.number]/* <--this is where I have the problem, can anyone
help! * for instance if the "table1.number" was 3 then it would pull back
.7*/
from table2
From table1
[505 byte] By [
david] at [2007-11-9 21:11:01]

# 1 Re: Stored Procedure column Name problem
david wrote:
> select [table1.number]/* <--this is where I have the problem, can
> anyone
SELECT table1.[7] FROM table1
--
Colin McGuigan
# 2 Re: Stored Procedure column Name problem
You need to build your SQL as a string and then use the EXEC SQL to run the
sql.
If I understand your question right, your tring to take the results of a
query and pass them as the field names to another query, the only way this
will work is if you use the EXEC SQL where SQL is the string concat of the
SQL you want to execute.
Eg.
Declare @SQL varchar 1000
SET @SQL = 'SELECT ' & Select Table1.number where table1.Limits=1 & ' FROM
table2
EXEC @SQL
Hope this helps,
Q*bert
"david" <d_canova@hotmail.com> wrote:
>
>I have a table with numbers for columns like so :
>columns --> category title [1] [2] [3]
> asp code .5 .3 .7
>
>i am pulling data from another table and using that data as a lookup on
this
>table. for instance.
>
>Select table1.number
>
>select [table1.number]/* <--this is where I have the problem, can anyone
>
>
>help! * for instance if the "table1.number" was 3 then it would pull back
>.7*/
>
>
>from table2
>
>
>
>
>From table1
Q*bert at 2007-11-11 23:53:03 >
