我想重新創建遠程服務器上承載的數據庫上的存儲過程。 當創建同一SP在本地我沒有得到任何錯誤,但是當我試圖創建遠程服務器上的SP,我得到這個錯誤:在遠程分區創建存儲過程附近的語法不正確
Msg 102, Level 15, State 1, Procedure MySP, Line 26
Incorrect syntax near 'MERGE'.
Msg 102, Level 15, State 1, Procedure MySP, Line 27
Incorrect syntax near 'S'.
這些錯誤在多個SP重複,我沒當我在本地服務器上創建SP時,無法獲取它們。 任何想法是什麼? 下面是一個簡單SP:
USE [MyDatabase]
GO
/****** Object: StoredProcedure [dbo].[InsertContractorInfo] Script Date: 11/07/2012 01:08:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
--exec [dbo].[InsertContractorInfo]
CREATE PROCEDURE [dbo].[InsertContractorInfo]
(@CompanyName nvarchar(50),
@LicenseNumber nvarchar(50),
@MailingAddress1 nvarchar(200),
@MailingAddress2 nvarchar(200),
@Phone nvarchar(10),
@Fax nvarchar(10),
@Mobile nvarchar(10),
@Email nvarchar(200),
@PercentCommercial int,
@PercentResidental int,
@TotalEmployees int,
@AnnualSales decimal(18,2),
@InsuranceCompanyContact nvarchar(100)=null,
@InsuranceCompanyContactEmail nvarchar(100)=null,
@InsuranceCompanyContactPhone nvarchar(100)=null,
@ContractorID uniqueidentifier)
AS
BEGIN
MERGE dbo.Contractor con
USING(SELECT 1 S) S
ON con.Oid = @ContractorID
WHEN MATCHED THEN UPDATE
SET
[CompanyName] = @CompanyName
,[LicenseNumber] = @LicenseNumber
,[MailingAddress1] = @MailingAddress1
,[MailingAddress2] = @MailingAddress2
,[Phone] = @Phone
,[Fax] = @Fax
,[EMail] [email protected]
,[Mobile] [email protected]
,[PercentCommercial] = @PercentCommercial
,[PercentResidental] = @PercentResidental
,[TotalEmployees] = @TotalEmployees
,[ApproximateAnnualSales] = @AnnualSales
,[InsuranceCompanyContact] = @InsuranceCompanyContact
,[InsuranceCompanyContactPhone] = @InsuranceCompanyContactPhone
,[InsuranceCompanyContactEmail] = @InsuranceCompanyContactEmail
WHEN NOT MATCHED THEN
INSERT
([Oid]
,[CompanyName]
,[LicenseNumber]
,[MailingAddress1]
,[MailingAddress2]
,[Phone]
,[Fax]
,[EMail]
,[Mobile]
,[PercentCommercial]
,[PercentResidental]
,[TotalEmployees]
,[ApproximateAnnualSales]
,[InsuranceCompanyContact]
,[InsuranceCompanyContactPhone]
,[InsuranceCompanyContactEmail])
VALUES
(@ContractorId
,@CompanyName
,@LicenseNumber
,@MailingAddress1
,@MailingAddress2
,@Phone
,@Fax
,@EMail
,@Mobile
,@PercentCommercial
,@PercentResidental
,@TotalEmployees
,@AnnualSales
,@InsuranceCompanyContact
,@InsuranceCompanyContactPhone
,@InsuranceCompanyContactEmail
);
END
GO
感謝,Laziale
檢查SQL Server版本。如果我記得,這個功能在2008年推出。 –