<small id='nyvxP'></small><noframes id='nyvxP'>

      <legend id='nyvxP'><style id='nyvxP'><dir id='nyvxP'><q id='nyvxP'></q></dir></style></legend>
      <tfoot id='nyvxP'></tfoot>

      <i id='nyvxP'><tr id='nyvxP'><dt id='nyvxP'><q id='nyvxP'><span id='nyvxP'><b id='nyvxP'><form id='nyvxP'><ins id='nyvxP'></ins><ul id='nyvxP'></ul><sub id='nyvxP'></sub></form><legend id='nyvxP'></legend><bdo id='nyvxP'><pre id='nyvxP'><center id='nyvxP'></center></pre></bdo></b><th id='nyvxP'></th></span></q></dt></tr></i><div id='nyvxP'><tfoot id='nyvxP'></tfoot><dl id='nyvxP'><fieldset id='nyvxP'></fieldset></dl></div>
      • <bdo id='nyvxP'></bdo><ul id='nyvxP'></ul>

        自增唯一标识符

        Autoincrement uniqueidentifier(自增唯一标识符)
          <tbody id='hxeRo'></tbody>

          1. <small id='hxeRo'></small><noframes id='hxeRo'>

            • <bdo id='hxeRo'></bdo><ul id='hxeRo'></ul>
              <i id='hxeRo'><tr id='hxeRo'><dt id='hxeRo'><q id='hxeRo'><span id='hxeRo'><b id='hxeRo'><form id='hxeRo'><ins id='hxeRo'></ins><ul id='hxeRo'></ul><sub id='hxeRo'></sub></form><legend id='hxeRo'></legend><bdo id='hxeRo'><pre id='hxeRo'><center id='hxeRo'></center></pre></bdo></b><th id='hxeRo'></th></span></q></dt></tr></i><div id='hxeRo'><tfoot id='hxeRo'></tfoot><dl id='hxeRo'><fieldset id='hxeRo'></fieldset></dl></div>
              <tfoot id='hxeRo'></tfoot>

                  <legend id='hxeRo'><style id='hxeRo'><dir id='hxeRo'><q id='hxeRo'></q></dir></style></legend>
                • 本文介绍了自增唯一标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  基本上我想以与身份类似的方式使用 uniqueidentifier.我不想在其中插入值,它应该只是自动插入值,每行不同的值.我无法在类型为 uniqueidentifier 的列上设置自动增量(属性自动增量"设置为 false 且不可编辑).

                  Basically I want to use uniqueidentifier in similar way as identity. I don't want to insert values into it, It should just insert values automatically, different value for each row. I'm not able to set autoincrement on columns of type uniqueidentifier(the property 'autoincrement' is set to false and is not editable).

                  推荐答案

                  或者更好:使用 newsequentialid() 作为 UNIQUEIDENITIFER 列的默认值.这将为您提供一系列有点顺序的 GUID.

                  Or even better: use the newsequentialid() as the default for your UNIQUEIDENITIFER column. That'll give you a somewhat sequential series of GUIDs.

                  CREATE TABLE dbo.YourTable   
                     (SerialID UNIQUEIDENTIFIER 
                          CONSTRAINT DF_SerialID DEFAULT newsequentialid(),
                       .... (other columns)......
                     )
                  

                  问题是:newsequentialid 可用作列默认值 - 您不能将其作为函数或任何东西调用.但这似乎符合您的要求.

                  Trouble is: newsequentialid is only available as a column default - you cannot call it as a function or anything. But that seems to fit your requirements.

                  更新:似乎在 SQL Server Management Studio 中存在一个公认的错误,该错误阻止将 newsequentialid() 指定为交互式表设计器中列的默认值.

                  UPDATE: there appears to be an acknowledged bug in SQL Server Management Studio that prevents specifying newsequentialid() as the default for a column in the interactive table designer.

                  请参阅:http://social.msdn.microsoft.com/Forums/en-US/sqltools/thread/cad8a4d7-714f-44a2-adb0-569655ac66e6

                  解决方法:创建您的表而不指定任何默认值,然后在正常查询窗口中输入此 T-SQL 语句并运行它:

                  Workaround: create your table without specifying any default, and then type in this T-SQL statement in a normal query window and run it:

                  ALTER TABLE dbo.YourTable
                      ADD CONSTRAINT DF_SerialID DEFAULT newsequentialid() FOR SerialID
                  

                  这应该可以解决问题!

                  这篇关于自增唯一标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Select n random rows from SQL Server table(从 SQL Server 表中随机选择 n 行)
                  SQL query to select dates between two dates(用于选择两个日期之间的日期的 SQL 查询)
                  How can I delete using INNER JOIN with SQL Server?(如何在 SQL Server 中使用 INNER JOIN 进行删除?)
                  Table Naming Dilemma: Singular vs. Plural Names(表命名困境:单数与复数名称)
                  INSERT statement conflicted with the FOREIGN KEY constraint - SQL Server(INSERT 语句与 FOREIGN KEY 约束冲突 - SQL Server)
                  Optimal way to concatenate/aggregate strings(连接/聚合字符串的最佳方式)
                  • <i id='sZYsT'><tr id='sZYsT'><dt id='sZYsT'><q id='sZYsT'><span id='sZYsT'><b id='sZYsT'><form id='sZYsT'><ins id='sZYsT'></ins><ul id='sZYsT'></ul><sub id='sZYsT'></sub></form><legend id='sZYsT'></legend><bdo id='sZYsT'><pre id='sZYsT'><center id='sZYsT'></center></pre></bdo></b><th id='sZYsT'></th></span></q></dt></tr></i><div id='sZYsT'><tfoot id='sZYsT'></tfoot><dl id='sZYsT'><fieldset id='sZYsT'></fieldset></dl></div>

                        <tbody id='sZYsT'></tbody>

                        1. <small id='sZYsT'></small><noframes id='sZYsT'>

                        2. <legend id='sZYsT'><style id='sZYsT'><dir id='sZYsT'><q id='sZYsT'></q></dir></style></legend>

                        3. <tfoot id='sZYsT'></tfoot>
                          • <bdo id='sZYsT'></bdo><ul id='sZYsT'></ul>