dest.map
dest.map

Reputation: 3

SQL select insert into trigger

USE [BASE]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER TRIGGER [dbo].[Trig1]
   ON [dbo].[Report]
   for Update
AS BEGIN

    INSERT INTO DeclarationApprover ( ApproverLevel,Approver)
    select(9,'asd')
    from inserted

END

ApproverLevel and Approver both are nvarchar

My query is giving the below error:

Incorrect syntax near ','.
select(9,'asd')

Upvotes: 0

Views: 46

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 522817

Remove the parentheses in your select clause:

INSERT INTO DeclarationApprover (ApproverLevel, Approver)
SELECT 9, 'asd'
FROM INSERTED;

You should not need to use an actual tuple in your select clause; just use a CSV list of literal values instead.

Actually, you should not even need FROM INSERTED, since you are not actually using any of the columns in that record, so the following should work:

INSERT INTO DeclarationApprover (ApproverLevel, Approver)
SELECT 9, 'asd';

Upvotes: 1

Related Questions