Solved

Error when creating a trigger

Posted on 2012-03-21
1
277 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

688 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