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 |
|
spope
Starting Member
2 Posts |
Posted - 2010-04-13 : 13:47:14
|
| We have a program that takes historical temperature and pressure readings for various sensors. When a log is setup the program creates another table in the database, and appends a master list table with the name of the new table and a description. If we have 10 different sensors that we are monitoring, the database will have 11 tables:tblTrend_0000 - filled with the trend data from sensor 0 . . .tblTrend_0009 - filled with the trend data from sensor 9tblMastList - filled with the following data Outside Temp tblTrend_0000 . . . Inside Temp tblTrend_0009We would like to be able to query the correct table based on the plain text description instead of having to know what the table name of the table that it is stored in. Is there a way to do this in SQL or are we going to be forced to do it in a higher level program?Thank you for your help. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
spope
Starting Member
2 Posts |
Posted - 2010-04-13 : 15:39:31
|
| That worked well for entering a new query directly, but everytime I try incorporate that into a function I get errors. When I try to do a table function, I get error on my first DECLARE @s. When I try to do scalar functions I get errors that I cannot return a datatype of table.Thanks! |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-04-15 : 08:31:02
|
| Make sure you read this fullywww.sommarskog.se/dynamic_sql.htmlMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|