473,414 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

query plan in clear text

hi.
coming from postgresql, i am used to textual references to most of the
things i do with the database. i feel a little lost with all the graphical.

i have few questions regarding MS SQL 2000
1. what is the best (or easiest) way of getting a table definition in text?
it could be either a CREATE TABLE sql-query or a just a definition,
something like:
TABLE thisTable
id integer
value varchar(10)
etc. etc.
2a. how do i get a query plan and how do i get it in text.
2b. are there planner modes that show more or less of what actually
happened, verbose mode perhaps?
2c. if i ask for a query plan, will SQL server actually run the query or
will it only produce a plan. if the query is run, does it commit or
rollback by default?
stig
Dec 11 '05 #1
7 2195
Hi

I assume you have found books online that will give you a great deal of
information regarding language/tools etc... the latest version can be
downloaded from
http://www.microsoft.com/downloads/d...DisplayLang=en

This will give you information on sp_help (and similar procedures) which
will give information regarding an object.

Scripting can be done from Enterprise Manager, the General SQL option will
create a script to create the object which can be written to a file or
pasted into another window. This can usually be found by right clicking the
item in the tree view.

There are also scripting options in Query Analyser if you display the object
browser. This gives you multiple options regarding how you want to script it
and where output should go. This is also usually a right click option.

John
You can look at sp_help
"stig" <_n*****************@yahoo.se> wrote in message
news:dn**********@oden.abc.se...
hi.
coming from postgresql, i am used to textual references to most of the
things i do with the database. i feel a little lost with all the
graphical.

i have few questions regarding MS SQL 2000
1. what is the best (or easiest) way of getting a table definition in
text?
it could be either a CREATE TABLE sql-query or a just a definition,
something like:
TABLE thisTable
id integer
value varchar(10)
etc. etc.
2a. how do i get a query plan and how do i get it in text.
2b. are there planner modes that show more or less of what actually
happened, verbose mode perhaps?
2c. if i ask for a query plan, will SQL server actually run the query or
will it only produce a plan. if the query is run, does it commit or
rollback by default?
stig

Dec 11 '05 #2
On Sun, 11 Dec 2005 20:31:37 +0100, stig wrote:
hi.
coming from postgresql, i am used to textual references to most of the
things i do with the database. i feel a little lost with all the graphical.
Hi Stig,

Answers inline.

i have few questions regarding MS SQL 2000
1. what is the best (or easiest) way of getting a table definition in text?
it could be either a CREATE TABLE sql-query or a just a definition,
something like:
TABLE thisTable
id integer
value varchar(10)
etc. etc.
John Bell already addressed this question.

2a. how do i get a query plan and how do i get it in text.
To get an execution plan in text, add
SET SHOWPLAN_TEXT ON
go
before your query.
When using Query Analyzer, you can also use either Query | Current
connection properties (for one connection) or Tools | Options |
Connection properties (to change the defaults) and add a tick before the
"Set showplan_text" option.
2b. are there planner modes that show more or less of what actually
happened, verbose mode perhaps?
I personally prefer the graphical version offered by Query Analyzer over
the text version offered by SET SHOWPLAN_TEXT ON, but both carry
essentially the same information.
2c. if i ask for a query plan, will SQL server actually run the query or
will it only produce a plan. if the query is run, does it commit or
rollback by default?


In QA, you can use Query | Display Estimated Execution Plan (Ctrl-L) to
get an estimate of the query plan without running the query, or you can
get the real execution plan, including statistics on actually processed
numbers of rows, by running the query with the option Query | Show
Execution Plan (Ctrl-K) turned on - this will actually run the query.

If you use the SET SHOWPLAN_TEXT ON option, the query will actualy be
run, unless you also activate the fmtonly option with the commands
SET FMTONLY ON
go
Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Dec 11 '05 #3
On Sun, 11 Dec 2005 20:31:37 +0100, stig wrote:

(snip)
if the query is run, does it commit or
rollback by default?


Hi Stig,

Sorry - clicked "Send" before answering the last question.

If the query is run, it will commit by default, unless:

a) you explicitly execute a BEGIN TRANSACTION command before it (in that
case, the transaction remains open until you explicitly ROLLBACK or
COMMIT it or until the connection is lost),

b) you have activated the inplicit_transactions option, in which case
SQL Server will act as there is a BEGIN TRANSACTION command even if you
didn't add it yourself, or

c) it aborts due to an error (in that case, it gets rolled back).

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Dec 11 '05 #4
stig (_n*****************@yahoo.se) writes:
coming from postgresql, i am used to textual references to most of the
things i do with the database. i feel a little lost with all the
graphical.


Here are some good news: you don't have to use it. Use Query Analyzer
for all your tasks, and leave Enterprise Manager to rot in a corner.

Personally, I do almost all tasks from Query Analyzer, and about the only
graphical thing there is the query plan. The only thing I do from
Enterprise Manager is to deal with jobs.


--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Dec 11 '05 #5
Hugo Kornelis (hugo@pe_NO_rFact.in_SPAM_fo) writes:
If you use the SET SHOWPLAN_TEXT ON option, the query will actualy be
run, unless you also activate the fmtonly option with the commands


No, SET SHOWPLAN_TEXT (and SHOWPLAN_ALL) ON turns off execution:

SET SHOWPLAN_TEXT ON
go
PRINT 'Showplan is ON'
go
SET SHOWPLAN_TEXT OFF
go
PRINT 'Showplan is OFF'
go

The command to use if you want plans and also execute, is
SET STATISTICS PROFILE ON.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Dec 11 '05 #6
On Sun, 11 Dec 2005 21:28:01 +0000 (UTC), Erland Sommarskog wrote:
Hugo Kornelis (hugo@pe_NO_rFact.in_SPAM_fo) writes:
If you use the SET SHOWPLAN_TEXT ON option, the query will actualy be
run, unless you also activate the fmtonly option with the commands


No, SET SHOWPLAN_TEXT (and SHOWPLAN_ALL) ON turns off execution:

SET SHOWPLAN_TEXT ON
go
PRINT 'Showplan is ON'
go
SET SHOWPLAN_TEXT OFF
go
PRINT 'Showplan is OFF'
go

The command to use if you want plans and also execute, is
SET STATISTICS PROFILE ON.


Hi Erland,

You're right. Thanks for putting me straight.

I guess it's time to write another 1000 lines of "never post without
testing" :-(

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Dec 12 '05 #7

"Hugo Kornelis" <hugo@pe_NO_rFact.in_SPAM_fo> wrote in message
news:ke********************************@4ax.com...
I guess it's time to write another 1000 lines of "never post without testing" :-(


No, you just have to create a query that does so.

Please post DDL and all statements. :-)

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)

Dec 13 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Thomas R. Hummel | last post by:
Hi, I was just helping a coworker optimize a query. He had two versions: one which used UNION for each value for which he was tallying results and another query which used GROUP BY. Here is an...
11
by: Eugenio | last post by:
Excuse me in advance fo my little English. I've got this stored procedure **************************************************************************** ********** declare @Azienda as...
3
by: Will Atkinson | last post by:
Hi All, I'm a relative newbie to SQL Server, so please forgive me if this is a daft question... When I set "Show Execution Plan" on in Query Analyzer, and execute a (fairly complex) sproc, I...
8
by: Együd Csaba | last post by:
Hi All, how can I improve the query performance in the following situation: I have a big (4.5+ million rows) table. One query takes approx. 9 sec to finish resulting ~10000 rows. But if I run...
6
by: Ryan | last post by:
I came across a situation that I've been unable to explain and was hoping somebody had an answer: I had written an update query which was taking about 8 seconds to run and considered it too...
2
by: Zygo Blaxell | last post by:
I have a table with a few million rows of temperature data keyed by timestamp. I want to group these rows by timestamp intervals (e.g. every 32 seconds), compute aggregate functions on the...
2
by: Keith C. Perry | last post by:
Ok, I've tried a number of things here and I know I'm missing something but at this point my head is spinning (i.e. lack of sleep, too much coffee, etc...) My environment is PG 7.4.3 on Linux...
4
by: traceable1 | last post by:
I am trying to improve the performance of a query. No matter how bad it runs the first time, it runs really fast the second time. So how can I tell if I've done anything to improve the query if...
1
by: Aaron West | last post by:
Try this script to see what queries are taking over a second. To get some real output, you need a long-running query. Here's one (estimated to take over an hour): PRINT GETDATE() select...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.