デフォルトのNEWID()でテーブルに列を追加し、既存の行を更新して新しいIDも持つ場合。あなたは
-- Create test table
CREATE TABLE Test1
(
ID int IDENTITY(1,1)
,Txt char(1)
);
-- Insert data
INSERT INTO Test1(Txt)
SELECT 'a' UNION ALL
SELECT 'b' UNION ALL
SELECT 'c' UNION ALL
SELECT 'd' UNION ALL
SELECT 'e';
-- Add column
ALTER TABLE Test1
ADD GlobalID uniqueidentifier DEFAULT(NEWID());
-- View table, default value not added for existing rows
SELECT *
FROM Test1;
-- Update null ids with guids
UPDATE Test1
SET GlobalID = NEWID()
WHERE GlobalID IS NULL
-- Insert new data
INSERT INTO Test1(Txt)
SELECT 'f' UNION ALL
SELECT 'g' UNION ALL
SELECT 'h' UNION ALL
SELECT 'i' UNION ALL
SELECT 'j';
-- View table
SELECT *
FROM Test1;
-- Drop table
DROP TABLE Test1