Solved

Error when creating a trigger

Posted on 2012-03-21
1
271 Views
Last Modified: 2012-03-21
I'm trying to create a simple trigger but I keep getting an error on creation that says

Msg 120, Level 15, State 1, Procedure tr_trnSOP10200_Delete, Line 13
The select list for the INSERT statement contains fewer items than the insert list. The number of SELECT values must match the number of INSERT columns.

The list seems to be the same

What am I missing?

The trigger is below

USE [compdb]
GO
/****** Object:  Trigger [dbo].[tr_trnSOP10200_Delete]    Script Date: 03/21/2012 22:45:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO




Create TRIGGER [dbo].[tr_trnSOP10200_Delete]
ON [dbo].[SOP10200] FOR DELETE
AS
BEGIN

/* Capture delete detail on SOP10200 */

      
INSERT INTO DYNAMICS_EXT.dbo.trnSOP10200_Detail
(      
      login_Name
    ,user_name
    ,spid
    ,hostname
    ,trnAction
      ,get_date
      , SOPTYPE
      , SOPNUMBE
      , LNITMSEQ
      , CMPNTSEQ
      , ITEMNMBR
      , ITEMDESC
      , NONINVEN
      , DROPSHIP
      , UOFM
      , LOCNCODE
      , UNITCOST
      , ORUNTCST
      , UNITPRCE
      , ORUNTPRC
      , XTNDPRCE
      , OXTNDPRC
      , REMPRICE
      , OREPRICE
      , EXTDCOST
      , OREXTCST
      , MRKDNAMT
      , ORMRKDAM
      , MRKDNPCT
      , MRKDNTYP
      , INVINDX
      , CSLSINDX
      , SLSINDX
      , MKDNINDX
      , RTNSINDX
      , INUSINDX
      , INSRINDX
      , DMGDINDX
      , ITMTSHID
      , IVITMTXB
      , BKTSLSAM
      , ORBKTSLS
      , TAXAMNT
      , ORTAXAMT
      , TXBTXAMT
      , OTAXTAMT
      , BSIVCTTL
      , TRDISAMT
      , ORTDISAM
      , DISCSALE
      , ORDAVSLS
      , QUANTITY
      , ATYALLOC
      , QTYINSVC
      , QTYINUSE
      , QTYDMGED
      , QTYRTRND
      , QTYONHND
      , QTYCANCE
      , QTYCANOT
      , QTYONPO
      , QTYORDER
      , QTYPRBAC
      , QTYPRBOO
      , QTYPRINV
      , QTYPRORD
      , QTYPRVRECVD
      , QTYRECVD
      , QTYREMAI
      , QTYREMBO
      , QTYTBAOR
      , QTYTOINV
      , QTYTORDR
      , QTYFULFI
      , QTYSLCTD
      , QTYBSUOM
      , EXTQTYAL
      , EXTQTYSEL
      , ReqShipDate
      , FUFILDAT
      , ACTLSHIP
      , SHIPMTHD
      , SALSTERR
      , SLPRSNID
      , PRCLEVEL
      , COMMNTID
      , BRKFLD1
      , BRKFLD2
      , BRKFLD3
      , CURRNIDX
      , TRXSORCE
      , SOPLNERR
      , ORGSEQNM
      , ITEMCODE
      , PURCHSTAT
      , DECPLQTY
      , DECPLCUR
      , ODECPLCU
      , QTYTOSHP
      , XFRSHDOC
      , EXCEPTIONALDEMAND
      , TAXSCHID
      , TXSCHSRC
      , PRSTADCD
      , ShipToName
      , CNTCPRSN
      , ADDRESS1
      , ADDRESS2
      , ADDRESS3
      , CITY
      , [STATE]
      , ZIPCODE
      , CCode
      , COUNTRY
      , PHONE1
      , PHONE2
      , PHONE3
      , FAXNUMBR
      , Flags
      , BackoutTradeDisc
      , OrigBackoutTradeDisc
      , GPSFOINTEGRATIONID
      , INTEGRATIONSOURCE
      , INTEGRATIONID
      , CONTNBR
      , CONTLNSEQNBR
      , CONTSTARTDTE
      , CONTENDDTE
      , CONTITEMNBR
      , CONTSERIALNBR
      , BULKPICKPRNT
      , INDPICKPRNT
      , ISLINEINTRA
      , SOFULFILLMENTBIN
      , MULTIPLEBINS
)
      
SELECT
      system_user)login_Name
    ,(user)user_name
    ,(@@spid)spid
    ,(host_name())hostname
    ,('Delete')trnAction
      ,(getdate())get_date      
      , SOPTYPE
      , SOPNUMBE
      , LNITMSEQ
      , CMPNTSEQ
      , ITEMNMBR
      , ITEMDESC
      , NONINVEN
      , DROPSHIP
      , UOFM
      , LOCNCODE
      , UNITCOST
      , ORUNTCST
      , UNITPRCE
      , ORUNTPRC
      , XTNDPRCE
      , OXTNDPRC
      , REMPRICE
      , OREPRICE
      , EXTDCOST
      , OREXTCST
      , MRKDNAMT
      , ORMRKDAM
      , MRKDNPCT
      , MRKDNTYP
      , INVINDX
      , CSLSINDX
      , SLSINDX
      , MKDNINDX
      , RTNSINDX
      , INUSINDX
      , INSRINDX
      , DMGDINDX
      , ITMTSHID
      , IVITMTXB
      , BKTSLSAM
      , ORBKTSLS
      , TAXAMNT
      , ORTAXAMT
      , TXBTXAMT
      , OTAXTAMT
      , BSIVCTTL
      , TRDISAMT
      , ORTDISAM
      , DISCSALE
      , ORDAVSLS
      , QUANTITY
      , ATYALLOC
      , QTYINSVC
      , QTYINUSE
      , QTYDMGED
      , QTYRTRND
      , QTYONHND
      , QTYCANCE
      , QTYCANOT
      , QTYONPO
      , QTYORDER
      , QTYPRBAC
      , QTYPRBOO
      , QTYPRINV
      , QTYPRORD
      , QTYPRVRECVD
      , QTYRECVD
      , QTYREMAI
      , QTYREMBO
      , QTYTBAOR
      , QTYTOINV
      , QTYTORDR
      , QTYFULFI
      , QTYSLCTD
      , QTYBSUOM
      , EXTQTYAL
      , EXTQTYSEL
      , ReqShipDate
      , FUFILDAT
      , ACTLSHIP
      , SHIPMTHD
      , SALSTERR
      , SLPRSNID
      , PRCLEVEL
      , COMMNTID
      , BRKFLD1
      , BRKFLD2
      , BRKFLD3
      , CURRNIDX
      , TRXSORCE
      , SOPLNERR
      , ORGSEQNM
      , ITEMCODE
      , PURCHSTAT
      , DECPLQTY
      , DECPLCUR
      , ODECPLCU
      , QTYTOSHP
      , XFRSHDOC
      , EXCEPTIONALDEMAND
      , TAXSCHID
      , TXSCHSRC
      , PRSTADCD
      , ShipToName
      , CNTCPRSN
      , ADDRESS1
      , ADDRESS2
      , ADDRESS3
      , CITY
      , [STATE]
      , ZIPCODE
      , CCode
      , COUNTRY
      , PHONE1
      , PHONE2
      , PHONE3
      , FAXNUMBR
      , Flags
      , BackoutTradeDisc
      , OrigBackoutTradeDisc
      , GPSFOINTEGRATIONID
      , INTEGRATIONSOURCE
      , INTEGRATIONID
      , CONTNBR
      , CONTLNSEQNBR
      , CONTSTARTDTE
      , CONTENDDTE
      , CONTITEMNBR
      , CONTSERIALNBR
      , BULKPICKPRNT
      , INDPICKPRNT
      , ISLINEINTRA
      , SOFULFILLMENTBIN
      , MULTIPLEBINS

FROM DELETED
      
      
END
0
Comment
Question by:jdr0606
1 Comment
 
LVL 39

Accepted Solution

by:
appari earned 500 total points
ID: 37750996
try changing

SELECT
      system_user)login_Name
    ,(user)user_name
    ,(@@spid)spid
    ,(host_name())hostname
    ,('Delete')trnAction
      ,(getdate())get_date      


to


SELECT
      system_user login_Name
    ,[user] user_name
    ,@@spid spid
    , host_name() hostname
    ,'Delete' trnAction
      ,getdate() get_date      
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now