SQL Server SQL异常“@errno”附近的语法不正确

toe95027  于 2023-02-03  发布在  其他
关注(0)|答案(1)|浏览(248)

我是Vb.net和Linq 2sql的新手,在这里发布问题之前,我在谷歌上搜索了解决方案,但我无法修复它,我尝试使用Vb.net和Linq 2sql将行插入数据库,SubmitChanges()函数返回“@errno”SQL异常附近的语法不正确。表相关触发器:

USE [Roster]
 GO
 /****** Object:  Trigger [dbo].[ti_profile]    Script Date: 11/14/2017 
 4:17:00 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER TRIGGER [dbo].[ti_profile] on [dbo].[PROFILE] AFTER  INSERT
AS 

BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

declare @ls_profile_code  varchar(6)
declare @errno int
declare @errmsg varchar(255)

--set @ls_profile_code = select inserted.profile_code from inserted

-- insert what ever was added to the object table and not yet been inserted or updated in the profile_access
insert into Profile_access (profile_code , object_code)

    select  (select inserted.profile_code from inserted) ,
            object_code
    from    Objects
    where   object_code not in

        (
            select  object_code
            from    Profile_access 
            where   profile_code = @ls_profile_code
        )



return

error:
raiserror @errno @errmsg
rollback transaction

END

有什么办法可以解决这个问题吗?

qxgroojn

qxgroojn1#

RAISEERROR()函数requires parentheses now。这在SQL Server 2008 R2和SQL Server 2012之间发生了变化。
所以这个:

raiserror @errno @errmsg

变成了这个

raiserror(@errmsg, @errno, 1)

相关问题