在 sql 的 uniqueidentifier 中设置一些默认的 guid 值
Set some default guid value in uniqueidentifier in sql
我需要在 SQL 的 uniqueidentifier 列中设置默认 guid 值,而不是 NEWID()
。
例如:TestTable中有一列TestID,需要设置默认的TestID为"DA74F684-B228-48D5-9692-69465BE6D720"
。
提前致谢。
这是您的脚本。
ALTER TABLE TestTable drop COLUMN TestID
ALTER TABLE TestTable ADD TestID uniqueidentifier DEFAULT cast('DA74F684-B228-48D5-9692-69465BE6D720' as uniqueidentifier);
然后,更新现有记录
UPDATE TestTable set TestID = 'DA74F684-B228-48D5-9692-69465BE6D720'
我需要在 SQL 的 uniqueidentifier 列中设置默认 guid 值,而不是 NEWID()
。
例如:TestTable中有一列TestID,需要设置默认的TestID为"DA74F684-B228-48D5-9692-69465BE6D720"
。
提前致谢。
这是您的脚本。
ALTER TABLE TestTable drop COLUMN TestID
ALTER TABLE TestTable ADD TestID uniqueidentifier DEFAULT cast('DA74F684-B228-48D5-9692-69465BE6D720' as uniqueidentifier);
然后,更新现有记录
UPDATE TestTable set TestID = 'DA74F684-B228-48D5-9692-69465BE6D720'