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
 General SQL Server Forums
 New to SQL Server Programming
 Simple Insert issue

Author  Topic 

AdamWest
Constraint Violating Yak Guru

360 Posts

Posted - 2012-02-17 : 10:38:03
Having trouble with the syntax of a simple insert.

I want to copy TableA to TableB after TableB has been modified so the first
Column is a new Column. I want to put the same value into each row of the new
Column.

Something like :

Insert into TableB
Select 'Constant', TableB.* from TableB

Can someone put me right?
Thanks

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2012-02-17 : 10:49:36
try SELECT INTO:
Select 
'Constant',
fileA.*
into
fileB
from
fileA
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-17 : 13:12:59
quote:
Originally posted by AdamWest

Having trouble with the syntax of a simple insert.

I want to copy TableA to TableB after TableB has been modified so the first
Column is a new Column. I want to put the same value into each row of the new
Column.

Something like :

Insert into TableB
Select 'Constant', TableB.* from TableB

Can someone put me right?
Thanks


if you want to modify TableB first do ALTER TABLE ...ADD... to create new column. then use above query to populate it

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -