| Author |
Topic |
|
divyaram
Posting Yak Master
180 Posts |
Posted - 2012-10-31 : 07:24:04
|
| HI All,I have table with 2 column first column is having a query .I want to get the result of that query in column2table is like thisQuery Resultselect * from Employee where E_ID=e001 1select * from Employee where E_ID=e002 2select * from Employee where E_ID=e003 3select * from Employee where E_ID=e004 4select * from Employee where E_ID=e005 5Regards,Divya |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-10-31 : 07:29:56
|
| I would go through row by row and execute getting the result into a variable then update the table.What datatype is the result column?==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
divyaram
Posting Yak Master
180 Posts |
Posted - 2012-10-31 : 07:35:36
|
varchar is the datatype...quote: Originally posted by nigelrivett I would go through row by row and execute getting the result into a variable then update the table.What datatype is the result column?==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy.
Regards,Divya |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-10-31 : 09:22:37
|
quote: Originally posted by divyaram varchar is the datatype...quote: Originally posted by nigelrivett I would go through row by row and execute getting the result into a variable then update the table.What datatype is the result column?==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy.
Regards,Divya
Not sure whay you've implemented like this as it requires an iterative logic to do row by row processing. what are these queries? are they coimpletely different ones or do they differ only in some parameters------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
divyaram
Posting Yak Master
180 Posts |
Posted - 2012-10-31 : 10:00:24
|
HI Visakh,They do differ because the parameter passed in the where conditions will differ and all are unique even.I Have generated a dynamic Sql and insert into a TempTable,i got the query like this.. and my requirement is like tht i should get the result set of this dynamic query.quote: Originally posted by visakh16
quote: Originally posted by divyaram varchar is the datatype...quote: Originally posted by nigelrivett I would go through row by row and execute getting the result into a variable then update the table.What datatype is the result column?==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy.
Regards,Divya
Not sure whay you've implemented like this as it requires an iterative logic to do row by row processing. what are these queries? are they coimpletely different ones or do they differ only in some parameters------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Regards,Divya |
 |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-10-31 : 21:42:37
|
| Better to have two tables.First table with the query and an ID (identity).Second results table with ID and rest of columns as in the query result.Then loop through the ID in the query table - execute the query results to temp table - then insert temp table results into the result table with the ID.Then you can reformat for presentation if you wish.Of course if this is the query you want you can just have the E_ID in the query table then run a single query to insert all the results into the results table. You could hold the query on another table with a replacement string to get the values from the parameters table if you wish - still a single query to run.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
divyaram
Posting Yak Master
180 Posts |
Posted - 2012-11-01 : 07:51:09
|
| is it possible to use sp_executesql @SQL in a column which has to loop thr the tableRegards,Divya |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-11-01 : 09:40:56
|
quote: Originally posted by divyaram is it possible to use sp_executesql @SQL in a column which has to loop thr the tableRegards,Divya
its possible but you've to call sp_executesql inside the loop if you want to iterate it through table column.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|