Wednesday, March 7, 2012

Copy and Past a row

Hello all,

Is there a way for me to copy a row, do some modification in a certain row and insert it to the same table as a new row?

Forward with thousand thanks.

Best regards,

Tee Song Yann

Where, in code in an application ? YOu will have to be a bit more specific.

Jens K. Suessmeyer.

http://www.sqlserver2005.de
|||

Hello Jens,

I'm trap in a pure SQL query's world. Imagine you are performing the above task in SQL Server Management Studio.

Best regards,

Tee Song Yann

|||Then you can just open a table with "Open Table" and select a row by clicking on the left side of the row (Selecting the whole column), STRG+C , go to the last row, which indicates a new row, STRG+V. Unless you leave the row, you will be able to change the values within, if you want to discard the insert or changes you can press ESC.

Jens K. Suessmeyer.

http://www.sqlserver2005.de
|||OR <ctrl>C and <ctrl>V|||

Sorry I think I guide you people to the wrong place.

Actually it should be "Imagine you are performing the above task in SQL Server Management Studio SQL Query".

Can I perform that with SQL statement only?

Thanks.

|||

OK, yes this is sure possible:

INSERT INTO SomeTable2
(ColumnListHereto Insert)
Select YourColumnsHere
From SomeTable
Where ConditionsTofilterYourRow

Instead of YourColumnsHere you can use any manipulation on the data you want like

REPLACE(SomeColumn, 'a','b'), LEFT(SomeOtherColum,3)

Jens K. Suessmeyer.

http://www.sqlserver2005.de

|||

Hello Jens,

Thanks for your help. Then I better post more question here. Wahaha.

Thanks again and best regards.

Tee Song Yann

No comments:

Post a Comment