简体   繁体   English

如何创建十六进制身份自动增量列sql server

[英]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.

相关问题 自动增加sql-server中的非标识列 - Auto Increment a non-identity Column in sql-server 在 SQL Server 2008 R2 中,有没有办法在不使用 IDENTITY(1,1) 的情况下创建自定义自动增量标识字段? - In SQL Server 2008 R2, is there a way to create a custom auto increment identity field without using IDENTITY(1,1)? 如何在sql server中创建字符和数字像字母数字的自动增量列? - how to create auto increment column with characters and number like alphanumeric in sql server? 如何在SQL Server中为自动增量列指定特定值? - How to specify a specific value for an auto increment column in SQL Server? SQL Server:如何创建具有自动增量的临时表? - SQL Server: how to create temp table with auto increment? SQL Server中的自动增量列值 - Auto Increment column values in SQL Server SQL 服务器中的自动增量列与 select - Auto increment column in SQL server with select 如何重新编号 T-SQL 的系统自增标识列? - How to re-number T-SQL's system auto-increment Identity column? SQL Server 2008身份密钥自动增量问题 - SQL Server 2008 identity Key auto increment Issue 如何向系统间缓存数据库中的现有列添加自动增量(IDENTITY) - How to add auto increment(IDENTITY) to existing column in intersystems cache database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM