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
 SQL Server Development (2000)
 Copy one row, select into?

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-04-01 : 09:12:26
Summer writes "Hei!
I think that this is what I basicly need. But I cant get it work in my stored prosedure, MS server 7.0

'From Books online
**The SELECT INTO statement retrieves one row of results. The SELECT INTO statement is also known as a singleton SELECT statement.

Syntax
SELECT [select_list] INTO {:hvar [,...]} select_options
SELECT au_lname INTO :name FROM authors WHERE stor_id=:id;
**

I want to copy one row in my database, and change primary key (example id + 1).
How should I do it then?

T:Summer"

Jay99

468 Posts

Posted - 2002-04-01 : 10:00:47
Post your CREATE TABLE statement (DDL).

Where do you want to 'paste' the row that you 'copy'?

Jay
<O>
Go to Top of Page

Summer
Starting Member

7 Posts

Posted - 2002-04-02 : 00:33:02
quote:

Post your CREATE TABLE statement (DDL).

Where do you want to 'paste' the row that you 'copy'?

Jay
<O>




In that same table.
I want make "basis/background" for my new order from old order(for example).
I think that is quite normal function, but I dont figure it out.
If possible, i dont want any new tables

regards
Summer

Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2002-04-02 : 01:44:34
Ahhh

You want to do something like


INSERT INTO Orders (CustomerID, PartID)
SELECT CustomerID, PartID
FROM Orders WHERE OrderID = 1


That should do it.

Damian
Go to Top of Page

Summer
Starting Member

7 Posts

Posted - 2002-04-04 : 03:16:48
Thanks very much!

That's what I was looking for

Summer



Go to Top of Page
   

- Advertisement -