【发布时间】:2012-09-18 17:26:18
【问题描述】:
我将创建一个由十六进制值组成的连续序列号
使用这种格式:
XX-XX-XX-YYYY
Which XX-XX-XX is default value
And YYYY is the incrementing hexa decimal value
现在要根据十六进制值创建序列号,我需要在最后生成的十六进制值上加 6
MIN: 2D41 + 6 = 2D47
2D47 + 6 ... and so on
MAX: 4100 generation of serial will stop when I meet the MAX value.
我已经在 c# 中创建了它,但我需要在 SQL 上完成它
int num1 = int.Parse("2D41", NumberStyles.HexNumber); //Convert hex to int
int result = num1 + 6; //Add + 6 for increment
string myHex = result.ToString("X"); //Convert result to hex
MessageBox.Show(myHex); // result 2D47
如何在 T-SQL 中做到这一点?
【问题讨论】:
标签: sql-server sql-server-2008 tsql type-conversion