facebook

mssql transact sql

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #264272 Reply

    szabolcsi
    Member

    Hello!

    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=1

    select * from ACCOUNT_OWNER where id=@var1;

    error message:

    Must declare the variable @var1

    Thanks:

    Zoltan Szabolcsi

    #264315 Reply

    Haris Peco
    Member

    Zoltan,

    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,

    #264318 Reply

    szabolcsi
    Member

    Sorry, 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.

    #264319 Reply

    Haris Peco
    Member

    Zoltan,

    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 Run

    Regards,

    #264320 Reply

    szabolcsi
    Member

    Thanks, 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.

    #264321 Reply

    Haris Peco
    Member

    Zoltan,

    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,

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: mssql transact sql

You must be logged in to post in the forum log in