473,779 Members | 2,078 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2213
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_transa ctions 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****@sommarsk og.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_rFa ct.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****@sommarsk og.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_rFa ct.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_rFa ct.in_SPAM_fo> wrote in message
news:ke******** *************** *********@4ax.c om...
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
2451
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 aproximation of what they were: Query #1: --------- SELECT 12 AS ,
11
5413
by: Eugenio | last post by:
Excuse me in advance fo my little English. I've got this stored procedure **************************************************************************** ********** declare @Azienda as varchar(3), @Utente as varchar(20), @DataDa as datetime, @DataA as datetime, @AreaDa as varchar(3), @AreaA as varchar(3),
3
5371
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 note that a particular query is reported as having a query cost of "71% relative to the batch" - however, this is nowhere near the slowest executing query in the batch - other queries which take over twice as long are reported as having costs in...
8
3271
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 simultaneously 4 similar queries it takes nearly 5 minutes instead of 4 times 9 seconds or something near of that. here is a sample query: select mertido, fomeazon, ertektipus, mertertek from t_me30 where fomeazon in (select distinct fomeazon...
6
4568
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 slow. I copied the SQL statement from the query and tried executing it from code which then ran in 1 second. To make sure that I didn't miss anything, I copied the SQL statement back into a query and tried running it again. It now also only took 1...
2
720
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 columns, and ultimately feed the result into a graph-drawing web thingy. I'm trying a few different ways to get what seems to be the same data, and seeing some odd behavior from the query planner. The table looks like this:
2
3842
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 with 512Mb of ram and swap. This was just upgraded from 7.4 (just to make sure I'm current). Some of my settings in postgresql are giving fatal errors but I don't think my issue is related to my query problems. I also have a laptop running with...
4
13812
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 it always comes back quickly after the first run? I assume the query/data/plan is in cache - how can I clean it out for my session? Thanks in advance for any help you can provide -
1
3484
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 count_big(*) from sys.objects s1, sys.objects s2, sys.objects s3, sys.objects s4, sys.objects s5 PRINT GETDATE()
0
9636
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10306
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10075
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7485
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6727
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5504
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.