gpt4 book ai didi

Sql 异常 '@errno' 附近语法不正确

转载 作者:行者123 更新时间:2023-12-02 20:35:36 25 4
gpt4 key购买 nike

我是 Vb.net 和 Linq2sql 的新手,在此处发布问题之前,我在 google 上搜索了解决方案,但无法修复它,我正在尝试使用 Vb.net 将行插入数据库,并且Linq2sql,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

关于如何解决这个问题的任何想法请..

最佳答案

RAISEERROR() 函数 requires parentheses now 。这在 Sql Server 2008 R2 和 Sql Server 2012 之间发生了变化。

所以这个:

raiserror @errno @errmsg

变成这样:

raiserror(@errmsg, @errno, 1)

关于Sql 异常 '@errno' 附近语法不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47286531/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com