일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- 시트 탭 사라짐
- Oracle
- 초딩수학
- 썸머노트
- Request.Form
- MSSQL
- CSV
- 스크롤 사라짐
- .csv
- 세로 스크롤 막대
- LEFT JOIN
- chart.js
- Kakao API Address
- 업비트
- 나만의 상점
- python
- Banker's rounding
- rounding
- Android
- Excel
- 일본여행
- upbit
- 한글깨짐
- league of legends
- MYSQL
- MS-SQL
- Banker's
- Aspose.cells
- 가로 스크롤 막대
- swift 화면전환
Archives
- Today
- Total
DBA
SQL에서 Unique Code 만들기 본문
728x90
반응형
SMALL
ident_current('table_name')
지정된 테이블 또는 뷰에 대해 생성된 마지막 ID값을 반환한다.
생성된 마지막 ID값은 임의의 세션및 범위에 대한 값일 수 있음.
table_name : ID 값을 반환할 테이블 이름, varchar 이며 기본값 없음.
반환형식 : numeric(38, 0)
declare
@currentDateTime datetime
, @expireDateTime datetime
, @codeZero varchar(38)
set @currentDateTime = getdate()
set @expireDateTime = '9999-12-31 23:23:59.997'
set @codeZero = '00000000000000000000000000000000000000'
insert into table_namevalues ('PRJ' + right(@codeZero + ltrim(ident_current('projectHistories')), 38)
, 'CAS' + right(@codeZero + ltrim(ident_current('projectHistories')), 38)
, 1, 0, 0, @currentDateTime, @currentDateTime, @expireDateTime)
select * from table_name
1 | PRJ00000000000000000000000000000000000001 | CAS00000000000000000000000000000000000001 | 1 | 0 | 0 |
2 | PRJ00000000000000000000000000000000000002 | CAS00000000000000000000000000000000000002 | 1 | 0 | 0 |
3 | PRJ00000000000000000000000000000000000003 | CAS00000000000000000000000000000000000003 | 1 | 0 | 0 |
4 | PRJ00000000000000000000000000000000000004 | CAS00000000000000000000000000000000000004 | 1 | 0 | 0 |
5 | PRJ00000000000000000000000000000000000005 | CAS00000000000000000000000000000000000005 | 1 | 0 | 0 |
6 | PRJ00000000000000000000000000000000000006 | CAS00000000000000000000000000000000000006 | 1 | 0 | 0 |
7 | PRJ00000000000000000000000000000000000007 | CAS00000000000000000000000000000000000007 | 1 | 0 | 0 |
8 | PRJ00000000000000000000000000000000000008 | CAS00000000000000000000000000000000000008 | 1 | 0 | 0 |
9 | PRJ00000000000000000000000000000000000009 | CAS00000000000000000000000000000000000009 | 1 | 0 | 0 |
10 | PRJ00000000000000000000000000000000000010 | CAS00000000000000000000000000000000000010 | 1 | 0 | 0 |
728x90
반응형
LIST
Comments