Austin Muts

Austin Muts

  • 1.4k
  • 329
  • 125.5k

Syntax problem with insert

Oct 13 2019 11:53 AM
Kindly help to sort syntax for insert statement below
 
DECLARE @SQL NVARCHAR(MAX) = '',
@DocDefID VARCHAR(36),
@AccountNumber VARCHAR(36)
BEGIN
SET @DocDefID = '45456666'
SET @AccountNumber = '988989'
SET @SQL = 'INSERT INTO EhldebtCounselling17wCancellationOfDebtReview(ID,DocDefID,DocNo,IDNumber,AccountNumber,PassportNumber,ClientNumber,ApplicationID,IndexedBy,DocumentType,FileExtension))
SELECT ''NEWID()'' , ''@DocDefID '', ''IDNumber'',''@AccountNumber'',''PassportNumber'',''ClientNumber'',''ApplicationID'',''IndexedBy'',''DocumentType'',''FileExtension'' FROM Shared_Services_Document WHERE DocumentType like ''EhldebtCounselling17wCancellationOfDebtReview'''

EXECUTE sp_executesql @SQL
END
 

Answers (1)