我編寫了一個存儲過程,我將其作爲參數傳遞一年。我有saledatestr
作爲varchar
列。我想選擇其中4個saledatestr
第一位數等於我的參數這裏是我的代碼:語法附近的語法不正確
if exists (select * from dbo.sysobjects
where id = object_id(N'[dbo].[spSaleCustomerYear]')
and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[spSaleCustomerYear]
GO
create procedure spSaleCustomerYear
(@year varchar)
with Encryption
as
select
c.CustomerCode,
PLE.PLEName,
s.SaleNo,
s.FinalPrice,
s.SaleDateStr
from
SMS.tblsales s
left join
SMS.tblCustomers c on c.CustomerID = s.CustomerRef
left join
GNR.tblPrincipalLegalEntities PLE on PLE.PrincipalLegalEntityID = c.PrincipalLegalEntityRef
where
s.CustomerRef not in (select CustomerRef
from SMS.tblSales s1
--left join dbo.tblFiscalYear FY on FY.FiscalYearID = s1.FiscalYearID
where (LEFT(s1.SaleDateStr, 4) = @year)
and SaleDocType = 4)
的錯誤是在這條線:
(LEFT(s1.SaleDateStr, 4) = @year)
請幫我傢伙。
在此先感謝。
你使用哪種數據庫管理系統?請爲其添加標籤 – Jens
請添加完整的錯誤消息 – Jens
@Jens Msg 102,Level 15,State 1,Line 3 '4'附近的語法不正確。 –