August 15, 2012 at 12:25 pm
Can someone assist me on the t-sql.
This is my current data:
ID role unit name bit1 bit2 bit3
2111A110
31611A110
4122A110
51622A110
6133A110
71633A110
8144A110
91644A110
I need to insert the similar data:
Column ID is the primary key and autoincrements.I need to insert similar rows but with name B under column name and with other similar data.
ID role unit name bit1 bit2 bit3
10111B110
111611B110
12122B110
131622B110
14133B110
151633B110
16144B110
171644B110
August 15, 2012 at 12:52 pm
sqlserver12345 (8/15/2012)
Can someone assist me on the t-sql.This is my current data:
ID role unit name bit1 bit2 bit3
2111A110
31611A110
4122A110
51622A110
6133A110
71633A110
8144A110
91644A110
I need to insert the similar data:
Column ID is the primary key and autoincrements.I need to insert similar rows but with name B under column name and with other similar data.
ID role unit name bit1 bit2 bit3
10111B110
111611B110
12122B110
131622B110
14133B110
151633B110
16144B110
171644B110
I think the following should work. Try it in a test environment.
INSERT INTO dbo.MyTable (role, unit, name, bit1, bit2, bit3)
SELECT
role, unit, 'B', bit1, bit2, bit3
FROM
dbo.MyTable
WHERE
name = 'A';
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply