2009. 5. 15. 17:13
제일 빠른 Table에 identity 추가방법 (MSSQL 2005) Work/SQL Server2009. 5. 15. 17:13
http://cafe.naver.com/sqlmvp/517
MSSQL 2005에서 가능한 것 같다.
CREATE TABLE taddy (번호 int not null, name varchar(24));
INSERT taddy
SELECT 1,'박찬호' UNION ALL
SELECT 2,'홍길동' UNION ALL
SELECT 3,'김연아' UNION ALL
SELECT 4,'유재석' UNION ALL
SELECT 5,'강호동';
CREATE TABLE taddy_id (번호 int identity(6,1) not null, name varchar(24));
ALTER TABLE taddy SWITCH TO taddy_id;
drop table taddy;
exec sp_rename 'taddy_id','taddy';
SELECT * FROM taddy;
switch 라는 기능 신기하다...