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.
| Author |
Topic |
|
only1rb
Starting Member
2 Posts |
Posted - 2007-10-22 : 10:52:13
|
| I have a template table that holds the field names of another table. I want to query the template table and get the fields names for the query to extract the real data from the Database. How do create a query that uses the fields from one table as field names in the second part of the query. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-10-22 : 10:53:11
|
http://www.sommarskog.se/dynamic_sql.html E 12°55'05.25"N 56°04'39.16" |
 |
|
|
only1rb
Starting Member
2 Posts |
Posted - 2007-10-22 : 11:39:52
|
| Thanks Peso for the response,ok, now I am even more confused. The information that you referred me to tells me that dynamic sql is a bad way to go. I don't think that I got the point. Could someone help me break this down?I have a Template table the has several different combinations and can be added to. Should I use multiple queries or go dynamic sql? My concerns are:1. Multiple queries Every time a new template is added a new query has to be written. Is this the best way? 2. Dynamic SQL Can it be done? Should I use it if it can be? Other than the sql injection what is the security risk?could someone please give me an example of a Dynamic Query and break it down as to what is going on in the query, so I can understand better. |
 |
|
|
|
|
|