May 3, 2010 at 11:39 am
I am getting this error below when running my insert command. I am using sql server 2008
error:
Msg 102, Level 15, State 1, Line 19
Incorrect syntax near ')'.
Code:
Insert Into dbo.CMS_NewVnd_Master(
[Site_NBR], [AuditCode], [AuditDesc], [PRGIndustryDesc],
[PRGSubIndustryDesc], [CorpClientDesc], [AuditStatus], [Client_Nbr],
[AuditYearDesc], [VendorCode], [VendorDesc], New_Vnd, New_Name,
GroupVendor, GroupType)
(Select [Site_NBR], [AuditCode], [AuditDesc], [PRGIndustryDesc],
[PRGSubIndustryDesc], [CorpClientDesc], [AuditStatus], [Client_Nbr],
[AuditYearDesc], [VendorCode], [VendorDesc], New_Vnd, New_Name,
'Blackhawk Network', 'GiftCard'
From (Select * from dbo.tblv_Claims_2006AndGreater As CL2006
Where Not Exists(Select 1 From dbo.CMS_NewVnd_Master AS cnv
Where cnv.Site_Nbr = CL2006.Site_Nbr AND
cnv.Client_Nbr = CL2006.Client_Nbr AND
cnv.VendorCode = CL2006.VendorCode AND
(cl2006.VendorDesc Like 'Blackhawk Net%' OR cl2006.VendorDesc Like 'Blackhawk Mark%' OR
cl2006.VendorDesc Like 'BLACKHAWK MRKTG%')
)
)
)
May 3, 2010 at 11:44 am
Two things; first, have you tried double clicking on the error message? That will take you directly to the line with the error.
Second, why the () around the outer select statement?
May 3, 2010 at 12:25 pm
I fixed the issue. See the code fixed below:
Insert Into dbo.CMS_NewVnd_Master(
[Site_NBR], [AuditCode], [AuditDesc], [PRGIndustryDesc],
[PRGSubIndustryDesc], [CorpClientDesc], [AuditStatus], [Client_Nbr],
[AuditYearDesc], [VendorCode], [VendorDesc], New_Vnd, New_Name,
GroupVendor, GroupType)
Select CL2006.[Site_NBR], CL2006.[AuditCode], CL2006.[AuditDesc], CL2006.[PRGIndustryDesc],
CL2006.[PRGSubIndustryDesc], CL2006.[CorpClientDesc], CL2006.[AuditStatus], CL2006.[Client_Nbr],
CL2006.[AuditYearDesc], CL2006.[VendorCode], CL2006.[VendorDesc], CL2006.New_Vnd, CL2006.New_Name,
'Blackhawk Network', 'GiftCard'
From dbo.tblv_Claims_2006AndGreater As CL2006
Where Not Exists(Select 1 From dbo.CMS_NewVnd_Master AS cnv
Where cnv.Site_Nbr = CL2006.Site_Nbr AND
cnv.Client_Nbr = CL2006.Client_Nbr AND
cnv.VendorCode = CL2006.VendorCode
) AND
(cl2006.VendorDesc Like 'Blackhawk Net%' OR cl2006.VendorDesc Like 'Blackhawk Mark%' OR
cl2006.VendorDesc Like 'BLACKHAWK MRKTG%')
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply