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 |
|
vision99
Starting Member
14 Posts |
Posted - 2009-06-22 : 05:21:33
|
| HI,am having one temporary table in that am inserting the Table Name from which i have to retrive the dataCREATE TABLE #SRCNAME( Source1 Varchar(20))INSERT INTO #SRCNAMESELECT DISTINCT 'PRMCL_'+SOURCEFROM PrmTableWHERE DATE = '06/17/2009'SELECT * FROM #SRCNAME will display result something likePRMCL_table1now my requirement is get the required columns data from 'PRMCL_table1'. using sql not using any cursors....plz give some idea...-Vision |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-22 : 05:24:40
|
There is no difference between a WHILE LOOP or a CURSOR.Have your manager notice this. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
vision99
Starting Member
14 Posts |
Posted - 2009-06-22 : 05:29:02
|
| am not using any WHILE LOOP here...., just i want to display results without using cursor...-Vision |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-22 : 05:31:09
|
And what if there are two records in the #SRCNAME table? E 12°55'05.63"N 56°04'39.26" |
 |
|
|
vision99
Starting Member
14 Posts |
Posted - 2009-06-22 : 05:36:37
|
| It will give only one record, b'coz prmtable have only one source for one date...INSERT INTO#SRCNAMESELECTDISTINCT 'PRMCL_'+SOURCEFROMPrmTableWHEREDATE = '06/17/2009'-Vision |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-06-22 : 05:51:21
|
| declare @table_name varchar(100)SELECT @table_name =Source1 FROM #SRCNAME EXEC('SELECT * FROM '+@table_name )MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|