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 |
|
vedjha
Posting Yak Master
228 Posts |
Posted - 2010-03-23 : 15:17:35
|
| Hello Friends, I have approax 45 rows insert into a new tablei have find rows from different table as select c1,c2,c3 from table where conditionit gives me one row data.i have find c4,c5 from CTE (Common table Expression)it gives me 45 rows dataI have to mixup these output and insert in a new tableas :insert into table2 ( c1,c2,c3,c4,c5)values(??/* fetch those rows which we have discuss up side. */)please help me to insert. :)Thank youhttp://kiransoftech.com |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-03-23 : 16:06:58
|
one way:declare @c1 int -- or whateverdeclare @c2 intdeclare @c3 intselect @c1=c1,@c2=c2,@c3=c3 from table where ...insert table2(c1,c2,c3,c4,c5)SELECT @c1,@c2,@c3,c4,c5 from (your select from CTE comes here and then you don't need a CTE) as dt No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|
|
|