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 2005 Forums
 Transact-SQL (2005)
 Copy using SQL

Author  Topic 

badinar
Starting Member

14 Posts

Posted - 2009-10-12 : 12:22:03
i want to copy a set of rows from a table, and insert these rows into the same table with a change to only 1 column

is this possible?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-10-12 : 12:32:05
Yes, use INSERT/SELECT:

INSERT INTO Table1 (Column1, Column2, Column3)
SELECT Column1, Column2, 'SomeNewValue'
FROM Table1
WHERE...

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-10-12 : 12:32:11
Yes.
What is to change?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-10-12 : 12:34:01

I'm too slow for an Almighty SQL Goddess...

"Let's begin with the premise that everything you've done up until this point was done too late."


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

badinar
Starting Member

14 Posts

Posted - 2009-10-12 : 15:00:24
Thats it.. exactly what i wanted.. thanks!!

quote:
Originally posted by tkizer

Yes, use INSERT/SELECT:

INSERT INTO Table1 (Column1, Column2, Column3)
SELECT Column1, Column2, 'SomeNewValue'
FROM Table1
WHERE...

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-10-12 : 15:05:34
You're welcome.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -