SQL执行设置错误的列值

时间:2014-07-11 14:34:45

标签: sql sql-server tsql

我有以下sql语句,当写入SourceMembers表时,guid列的字符串'guid'写入每列。
这是下面的语法这样做,还是来自临时表SourceMembers的问题?

SET IDENTITY_INSERT [Groups].[dbo].[%1Members] OFF 

INSERT INTO SOURCEMEMBERS 
            ([GROUPID], 
             [GUID]) 
SELECT CONVERT(INT, GROUPID), 
       'guid' 
FROM   [#SOURCEMEMBERS] 

1 个答案:

答案 0 :(得分:0)

你把guid放在单引号中,假定它是一个字符串常量。相反,你想获取guid列,因此删除guid周围的单引号。

运行此

SET IDENTITY_INSERT [Groups].[dbo].[%1Members] OFF 
INSERT INTO SourceMembers ([GroupID],[guid]) 
SELECT CONVERT(INT, GroupID),guid FROM [#SourceMembers]