NetPochi


hello. A question please. What is the separator for sql statements in SqlServer   I'd want to write many statements and then depending on the cursor position, to execute it.

 Thanks...




Re: What is the separator of sql statements

Arnie Rowland


A semi-colon should work just fine.





Re: What is the separator of sql statements

NetPochi

Thanks. Another question please. when I do:

select * from customer;
select * from master;

I see the information of the 2 tables. Are there a way to only see 1 table depending on the cursor position

Thanks in advance






Re: What is the separator of sql statements

ManiD

From Where r u executing this query (which Front End, QA, ADO.NET - DataSet/DataReader, ADO.. )




Re: What is the separator of sql statements

NetPochi

In Sqlserver Management Studio. New Query. Thanks...



Re: What is the separator of sql statements

Duncan McC

You can Join the tables togteher if you have a unique ID. like follows:-

select *

from (customer left join master on unique ID)





Re: What is the separator of sql statements

NetPochi

Thanks. Not, That is not I want. I'd want to see 1 table depending on the cursor position.



Re: What is the separator of sql statements

Arnie Rowland

It would be very courteous if you were to indicate that your original question was properly answered, and by whom.

And then post your new question separately. This seems an abuse of the 'feedback' system.






Re: What is the separator of sql statements

Dinakar

I belive what you are asking for is not possible. You are probably looking for something that looks like a debugging mode where you can see the results from first query and when you hit continue you see the results from 2nd query etc.



Re: What is the separator of sql statements

NetPochi

I am sorry Arnie Rowland. I wanted 2 things in the same question, but one related to the other another. Separator and execution depending on the cursor. I do that with another database and It works fine.

Anyway you are rigth.

to say that the question was properly answered, must I click on "Mark as answer" on your post

Thanks you and I'm sorry...





Re: What is the separator of sql statements

Arnie Rowland

Yes, that would be the appropraite response. Thanks.




Re: What is the separator of sql statements

David Frommer

If you are in the query window of SQL Server Management Studio, you can highlight just a portion of the query and press execute to execute that part.




Re: What is the separator of sql statements

Louis Davidson

First your original question. The semicolon CAN seperate SQL Statements, but TSQL does not require a statement terminator. The query compiler knows how to seperate statements in most cases without one. There are a couple of situations in SQL Server 2005 where you must use a semicolon now when there are multiple statements (like before a CTE).

For your second question, technically this is not possible. Code in SQL Server is not tightly coupled with the editor as much as it is in .NET languages. There is little interaction between the UI and the compiler. So just placing your cursor on a statement will not give the expected results. When you press go, it just sends all of the code in the code window to be compiled, then executed.

You can highlight a statement (or statements) and then the higlighted code will be executed. So you can sort of do what you want, but not exactly.