0
CREATE TABLE dbo.Ids
( 
   DlId nvarchar(32) NOT NULL PRIMARY KEY,
   DlIdGUID uniqueidentifier NOT NULL
)

INSERT INTO dbo.Ids
(DlId, REPLACE(DlId, DlId, newid()))
(SELECT DISTINCT TOP 5 DriversLic FROM Student.dbo.StudDL
WHERE DlId LIKE '%345%')

エラーは言う

'(' 付近の構文が正しくありません

4

1 に答える 1

0

一致するDriversLicGUID と新しい GUID を挿入するには;

INSERT INTO dbo.Ids (DlId, DlIdGUID)
    (SELECT DISTINCT TOP 5 DriversLic, NEWID() 
     FROM Student.dbo.StudDL 
     WHERE DlId LIKE '%345%')

DISTINCT:

;with T(DriversLic) as (
    select distinct top 5 DriversLic from StudDL 
)
insert Ids  
    select DriversLic, NEWID() from T
于 2013-08-05T18:22:32.430 に答える