使用SQuirreL SQL Client创建SQL Server触发器的问题 [英] Issues Creating SQL Server triggers using SQuirreL SQL Client

查看:121
本文介绍了使用SQuirreL SQL Client创建SQL Server触发器的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我一直在使用SQL Server数据库,并且尝试使用SQuirreL SQL Client为某些表创建一些触发器,由于某种原因,我无法摆脱以下令人讨厌的错误消息:

Recently I have been working with a SQL Server database and I was trying to create some triggers for some tables using SQuirreL SQL Client and for some reason I was unable to get rid of the following pesky error message:

"错误:"CREATE TRIGGER"必须是查询批处理中的第一条语句. SQL状态:S0001 错误代码:111"

"Error: 'CREATE TRIGGER' must be the first statement in a query batch. SQLState: S0001 ErrorCode: 111"

我试图执行的查询如下(我从一个非常简单的触发器开始,以确保语法正确):

The query I was attempting to execute was the following (I started out with a really simple trigger to make sure the syntax was correct):

CREATE TRIGGER meeting_overlap on adhoc_meeting
FOR INSERT
AS
DECLARE
    @myvar INT

当我尝试在Microsoft SQL Server Management Studio Express中执行完全相同的查询时,它执行得很好.我的问题是:是否有其他人使用SQuirreL SQL Client遇到类似的问题?如果是,您该怎么做才能消除此错误?

When I attempted to execute my exact same query in Microsoft SQL Server Management Studio Express it executed fine. My question is: has anyone else run into similar problems using SQuirreL SQL Client and if so, what did you do to get rid of this error?

我正在将SQuirrel SQL v2.6.8与Microsoft SQL Server JDBC Driver 2.0配合使用,并且正在连接到SQL Server 2005.

I am using SQuirrel SQL v2.6.8 with the Microsoft SQL Server JDBC Driver 2.0 and I am connecting to SQL Server 2005.

推荐答案

我遇到了同样的问题.经过一番谷歌搜索,我发现了这篇文章:

I was having the same problem. After some Googling, I found this article:

http://vsingleton.blogspot .com/2009/04/error-create-view-must-be-first.html

简而言之,将exec('')包裹在创建触发器语句中.此外,您需要将触发器语句中的任何单引号(')更改为双单引号('').

In short, wrap exec('') around your create trigger statement. In addition, any single quotes (') you have in the trigger statement need to be changed double single quotes ('').

这篇关于使用SQuirreL SQL Client创建SQL Server触发器的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆