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)
 How To Duplicate A Few row with parameter and change some field value?

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-09-24 : 09:08:34
sk_koh writes "Hi,

I need duplicate a few row data and insert it back to the same
table with parameter and aslo need to change some value.( Copy ).

MyTable
=============
SPID int identity(1,1)
Spdid int
Name char(10)
Address char(10)
Status Char(10)

Data as below. This is a example table content data

SPID   Spdid   Name   Address   Status
1 24 AAA BBPPP ok
2 24 ABB ABBBB ok
3 24 ABC GGGGG no
5 25 GGG HHHHH ok
6 25 GGy Hjjjk ok
7 25 GGk Hiijk ok
8 26 G59 HH55H on
9 26 G78 Hj45k ok
10 26 G99 Hi66k on


Here i need to copy data where Spdid is 24 so it has 3 row.
That i need it insert back into the table (same table). and
change Spdid into 28. So the data is as below.

SPID   Spdid   Name   Address   Status
1 24 AAA BBPPP ok
2 24 ABB ABBBB ok
3 24 ABC GGGGG no
5 25 GGG HHHHH ok
6 25 GGy Hjjjk ok
7 25 GGk Hiijk ok
8 26 G59 HH55H on
9 26 G78 Hj45k ok
10 26 G99 Hi66k on
11 28 AAA BBPPP ok
12 28 ABB ABBBB ok
12 28 ABC GGGGG no


How can i write a store procedure for this?
I am new in store procedure, Can you pls help me.

Tks / sk_koh"
   

- Advertisement -