- This topic has 5 replies, 2 voices, and was last updated 17 years, 9 months ago by Haris Peco.
-
AuthorPosts
-
szabolcsiMemberHello!
Can I run Transact-SQL commands in sql editor? What is the trick? The code below produce an error message
code:
declare @var1 int;
@var1=1select * from ACCOUNT_OWNER where id=@var1;
error message:
Must declare the variable @var1
Thanks:
Zoltan Szabolcsi
Haris PecoMemberZoltan,
If you use MyEclipse >= 5.0 you have to use command separator (some different than ; , choose ‘go’ for example ) and sparate your commands with separator.
Command separator is in SQL Editor’s combo closed to catalog combo.
Regards,
szabolcsiMemberSorry, but the separator is unimportant. It was only a copy mistake. If You try a correct code:
DECLARE @var1 int;
SET @var1 = 1;
SELECT * FROM ACCOUNT_OWNER WHERE id = @var1;You will see that the error message is the same. But it works well in Microsoft SQL Server Enterprise Manager.
Haris PecoMemberZoltan,
I am talking about command separator in MyEclipse.MyEclipse use ‘;’ by default and send command after ‘;’ to server, but server can understand only complete your command.
Please try next :
– Type your sql in sql editor
DECLARE @var1 int;
SET @var1 = 1;
SELECT * FROM ACCOUNT_OWNER WHERE id = @var1;
go– change command separator (you will see default ‘;’ in combo right to catalog) to ‘go’ – you can choose ‘go’ from combo or type your command separator in combo – combo is editable.
– call RunRegards,
szabolcsiMemberThanks, I figured out it. The three line separated by “;” is only one command when I use “go” separator and this is the correct syntax . This is one command in transaction sql. The code below is working too if I use “;” separator:
DECLARE @var1 int
SET @var1 = 1
SELECT * FROM ACCOUNT_OWNER where id=@var1;I have thought about “;” as a line separator, not command separator.
Thanks for the express replay.
Haris PecoMemberZoltan,
It is important that you know that MyEclipse send command to server after command separator (what ever you set in combo).Server will not recognize incomplete command, like this :
SET @var1 = 1
with or without line separator
I’m glad for your success
Regards,
-
AuthorPosts