【问题标题】:How can I generate same GUID for one subscriber with multiple records in SQL Server如何在 SQL Server 中为具有多条记录的一个订阅者生成相同的 GUID
【发布时间】:2018-04-27 03:19:53
【问题描述】:

我有一个名为 membertable 有 4 列 memberid(它是 GUID column)、subscriber key(订阅者和依赖者都将相同)、First name(它包含订户及其家属)和Last name(它包含订户及其家属的姓氏)。

目前,我正在获取所有记录的唯一 GUID 值,例如:如果表中有 4 条记录,member 的 2 条记录和依赖的 2 条记录,GUID 值所有 4 条记录都不同。

但是对于 2 个成员记录,我需要相同的 GUID 值和从属记录的另一个 GUID 值。请让我知道如何在 SQL Server 中获取此信息。

【问题讨论】:

标签: sql-server tsql ssis


【解决方案1】:
--Test data
create table #temp_table  (col1 uniqueidentifier , co12 uniqueidentifier , col3 uniqueidentifier);

--use variable save the guid,when insert use it
DECLARE @guid uniqueidentifier  
SET @guid = NEWID() ;
insert into #temp_table (col1,co12,col3) values (@guid,@guid,@guid);

--result
select * from #temp_table;

希望能帮到你:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-21
    • 1970-01-01
    相关资源
    最近更新 更多