sql-mssql

mssql tips

UNIQUEIDENTIFIER사용 및 insert시 값 가져오기

1
CREATE TABLE TY (  
2
   Y_id UNIQUEIDENTIFIER DEFAULT (newsequentialid()) PRIMARY KEY,
3
   Y_name varchar(20) NULL,
4
);  
5
declare @guid table (Y_id UNIQUEIDENTIFIER);
6
7
INSERT into TY(Y_name)
8
output INSERTED.Y_id into @guid
9
VALUES ('Rosalie');
10
11
SELECT (select top(1) Y_id from @guid) as blabla
12
13
SELECT * FROM TY;  
14
15
drop table TY;

newdate

1
select GETDATE() as newdate
Share