SQLTeam.com | Weblogs | Forums

Create interrogation Sql from istruction in sql table


#1

Hello
Forgive my English first ...
I need to create a select statement that resituisca me over the fields that I point , an additional field by taking the sql statement that is contained within a field .
Example:
select username , full name, formula ... in formula exists written a select statement that indicates the education of everyone who sees the username and therefore I need to return the list in a field ...
Thank you


#2

Can you give me sample data and output?


#3

TABLE1
CODE,NAME,SECOND NAME,...
1000,LEWIS,HAMILTON,...
1001,NICO,ROSBERG,...
1002,FERNANDO,ALONSO,...

TABLE2
USERNAME,FORMULA
LHAMILTON,SELECT * FROM CODE IN(1001,1002,1003,...)

RESULT
LHAMILTON,1001 NICO ROBERG,1002 FERNANDO ALONSO,1003 ....

ok?


#4
Select Username, (Select code + ' ' + name + ',' secondname from table1 for xml path('')) 
from table2

#5

for xml path('') ?

Excuse me , are those values ​​in sql tables , I am preparing a data extraction query ....
in Table 2 , there lies the formula, and I just want to execute the statement is in the formula column .... the instructions may be different ...

Many thanks

TABLE1
CODE,NAME,SECOND NAME,...
1000,LEWIS,HAMILTON,...
1001,NICO,ROSBERG,...
1002,FERNANDO,ALONSO,...

TABLE2
USERNAME,FORMULA
LHAMILTON,SELECT * FROM CODE IN(1001,1002,1003,...)
FMASSA,SELECT * FROM CODE=(2950,2960)

RESULT
LHAMILTON,1001 NICO ROBERG,1002 FERNANDO ALONSO,1003 ....

ok?


#6

You need to execute the formula separately. and join with the tables


#7

I could also make a view that takes those that there ' written in the field but the query statement is that there ' s in the formula column
ok?


#8

I could also make a view that takes those that there ' written in the field but the query statement is that there ' s in the formula column
ok?