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 |
|
real_pearl
Posting Yak Master
106 Posts |
Posted - 2004-08-16 : 06:19:12
|
| If we have a table name stored in a column, can we treat this columns value as a table name in anouther query without building and executing the query string. Suppose we store that table_name in a variable in the example below, can we run this query successfully (either way). Please tell me if anybody knows a waydeclare @table_name varchar(255)set @table_name = 'P9240502_001'select wafer.wafer_sequencefrom wafer join @table_name ON wafer.wafer_sequence = @table_name.wafer_sequence |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-08-16 : 07:35:06
|
| you can't do it like that.build a string and use exec.declare @table_name varchar(255)set @table_name = 'P9240502_001'exec('select wafer.wafer_sequencefrom wafer join @table_name ONwafer.wafer_sequence = ' + @table_name + '.wafer_sequence')Go with the flow & have fun! Else fight the flow :) |
 |
|
|
real_pearl
Posting Yak Master
106 Posts |
Posted - 2004-08-16 : 07:38:38
|
| I have already done this. can I chat with u on yahoo? |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-08-16 : 07:50:07
|
| via mail you can. i haven't done anything else there, or you can try icq if you have it, msn messenger is ok too :))Go with the flow & have fun! Else fight the flow :) |
 |
|
|
|
|
|