티스토리 뷰

🌈 MsSql

포멧(format) 과 시퀀스(sequence)

James Wetzel 2022. 3. 22. 17:17
728x90
반응형
create sequence dbo.seq_name
as [int]
start with 1
increment by 1
maxvalue 999999
    
declare @grn_sequence_no int = next value for dbo.seq_name
select format(getdate(), 'yyyyMMdd') + '-' + format(@grn_sequence_no, 'd6')

 

 

참조 자료]

날짜 및 시간 스타일

https://docs.microsoft.com/ko-kr/sql/t-sql/functions/cast-and-convert-transact-sql?view=sql-server-2017 

 

포멧(Format)

https://docs.microsoft.com/ko-kr/sql/t-sql/functions/format-transact-sql?view=sql-server-ver15 

 

시퀀스(Sequence)

https://docs.microsoft.com/ko-kr/sql/t-sql/statements/create-sequence-transact-sql?view=sql-server-ver15

 

시퀀스(Sequence) 삭제

https://docs.microsoft.com/ko-kr/sql/t-sql/statements/drop-sequence-transact-sql?view=sql-server-ver15

 

 

 

 

 

 

 

 

728x90
반응형