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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 using Data Reader

Author  Topic 

saidev
Posting Yak Master

101 Posts

Posted - 2006-08-17 : 17:15:24
Hi Guys,
i have a table called tbl A, and there is are 4 columns. Here is the Data

tbl A

1 2 3 4
0 0 0 0
0 0 9 0
0 0 0 0
what i want is i want to insert '9' from column 3 to another table as a first column in all the rows. It should be like this

tbl B
1 2 3 4
9 0 0 0
9 0 0 0
9 0 0 0

can you guys help me with the Query.
Thanks


Gopi Nath Muluka
Starting Member

22 Posts

Posted - 2006-08-17 : 18:55:58
I didn't understand your problem clearly

Try this,

insert into tblB
select col3,0,0,0 from tblA where col3=9
union all
select col3,0,0,0 from tblA where col3=9
union all
select col3,0,0,0 from tblA where col3=9

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-08-17 : 20:23:13
[code]insert into tblB (col1, col2, col3, col4)
select a.col3, a.col1, a.col2, a.col4
from tblA a cross join tblA aa
where a.col3 = 9[/code]


KH

Go to Top of Page
   

- Advertisement -