[英]how to create hexadecimal identity auto increment column sql server
Can anyone tell me how to create an identity column with auto increment storing hexadecimal values in sql server 2008 r2? 谁能告诉我如何在SQL Server 2008 R2中创建一个具有自动增量存储十六进制值的标识列? (I am looking for this function to use as OrderID and PaymentID in my small time shopping cart)
(我正在寻找此功能在我的小型购物车中用作OrderID和PaymentID)
SQL doesn't have native hex data type. SQL没有本地十六进制数据类型。 You can save it as varbinary, but still it would need conversion.
您可以将其另存为varbinary,但是仍然需要转换。
SELECT CONVERT( VARBINARY(8), 100)
--> 0x00000064
I would say that you use new computed column where you put these hex values, and let identity column remain int. 我会说,您使用新的计算列来放置这些十六进制值,并让标识列保持为整型。
您可以使用NEWSEQUENTIALID(),但不能使用顺序的但唯一的
col uniqueidentifier default NEWSEQUENTIALID()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.