[MSSQL] Identity 속성 제어하기
Database / 2012. 3. 29. 15:41
1. 현재값 확인
SELECT current_id = IDENT_CURRENT('Table_Name')
2. 초기화
DBCC CHECKIDENT('TableName', RESEED, 0)
3. 재설정
DBCC CHECKIDENT('TableName', RESEED)
현재 row 수 기준으로 초기화
|
1. 현재값 확인
SELECT current_id = IDENT_CURRENT('Table_Name')
2. 초기화
DBCC CHECKIDENT('TableName', RESEED, 0)
3. 재설정
DBCC CHECKIDENT('TableName', RESEED)
현재 row 수 기준으로 초기화
재귀 호출을 이용한 BinarySearch
선행: 정렬되어 있어야한다.
01.
//C#
02.
public
int
BinarySearch(
int
[] arr,
int
value,
int
low,
int
high)
03.
{
04.
if
(low > high)
05.
return
-1;
06.
int
mid = (low + high) / 2;
07.
if
(value == arr[mid])
08.
return
mid;
09.
else
if
(value > arr[mid])
10.
return
BinarySearch(arr, value, mid + 1, high);
11.
else
12.
return
BinarySearch(arr, value, low, mid - 1);
13.
}
14.
15.
16.
17.
// Main 은 이정도만..
18.
void
Main(
string
[] args)
19.
{
20.
int
[] arr = { 13, 22, 33, 42, 56, 63, 72, 87, 94, 100 };
21.
Console.WriteLine(BinarySearch(arr, 100, 0, arr.Length - 1).ToString());
22.
}
1.
// 컴파일 타임 상수
2.
public
const
int
_Millennium = 2000;
3.
// 런타임 상수
4.
public
static
readonly
int
_ThisYear = 2011;
1.
if
(myDatatime.Year == 2000)
1.
public
class
UsefulValues
2.
{
3.
public
static
readonly
int
StartValue = 5;
4.
public
const
int
EndValue = 10;
5.
}
1.
for
(
int
i = UsefulValues.StartValue; i < UsefulValues.EndValue; i++)
2.
{
3.
Console.WriteLine(
"Value is {0}"
, i);
4.
}
결과)
Value is 5
Value is 6
...
Value is 9
시간이 지나 새로운 버전을 다음과 같이 수정하였다.
1.
public
class
UsefulValues
2.
{
3.
public
static
readonly
int
StartValue = 101;
4.
public
const
int
EndValue = 120;
5.
}