Showing posts with label statements. Show all posts
Showing posts with label statements. Show all posts

Thursday, February 16, 2012

Bring back Query Analyser

Hi,
I am using 2005 SQL Management to edit my T-SQL stuff but it reformats all
of my SQL statements (just like Enterprise Manager) making complex
statements impossible to read.
Can anyone tell me if there any options to turn this off and/or an
alternative?
Thanks for any help,
Steve.I am using 2K5 SQL Management, your problem doesn't occur at my site.
Do you use query builder?
Steve Lloyd wrote:
> Hi,
> I am using 2005 SQL Management to edit my T-SQL stuff but it reformats all
> of my SQL statements (just like Enterprise Manager) making complex
> statements impossible to read.
> Can anyone tell me if there any options to turn this off and/or an
> alternative?
> Thanks for any help,
> Steve.|||Hi, thanks for the reply,
Ok, find out a few more things... Stored procedures open using query builder
and I can retain the formatting but Views open Enterpise Manager style and I
can't work out how to stop it...
Thanks again
Steve
<navyzhu@.gmail.com> wrote in message
news:1149757541.865478.194360@.h76g2000cwa.googlegroups.com...
>I am using 2K5 SQL Management, your problem doesn't occur at my site.
> Do you use query builder?
> Steve Lloyd wrote:
>|||Steve Lloyd (steve.remove@.livenowpaylater.this.co.uk) writes:
> Ok, find out a few more things... Stored procedures open using query
> builder and I can retain the formatting but Views open Enterpise Manager
> style and I can't work out how to stop it...
Stop using the Query Designer.
After all, since the subject line says bring back "Query Analyzer", you
should be used to be without the Query Designer as it is not present in
Query Analyzer.
As long as you stick to the regular query editor in Mgmt Studio, there
should be no reformatting.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||In addition to Erland's post:
Keep your DDL scripts somewhere safe, and only use them to create/alter/drop
SQL objects.
ML
http://milambda.blogspot.com/|||OK, it think I'm not making myself clear.. I want to be able to edit my
Views, Query Analyzer style, but when I open them in SQL Management they
default to the Query Builder and I can't work out how to open them without.
Sorry for the confusion...
"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns97DC7DAD2FAEBYazorman@.127.0.0.1...
> Steve Lloyd (steve.remove@.livenowpaylater.this.co.uk) writes:
> Stop using the Query Designer.
> After all, since the subject line says bring back "Query Analyzer", you
> should be used to be without the Query Designer as it is not present in
> Query Analyzer.
> As long as you stick to the regular query editor in Mgmt Studio, there
> should be no reformatting.
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/pr...oads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodin...ions/books.mspx|||Right click on the view
DO NOT select modify view
Instead choose Script View as -->ALTER To--> New Query window
Denis the SQL Menace
http://sqlservercode.blogspot.com/
Steve Lloyd wrote:
> OK, it think I'm not making myself clear.. I want to be able to edit my
> Views, Query Analyzer style, but when I open them in SQL Management they
> default to the Query Builder and I can't work out how to open them without
.
> Sorry for the confusion...
> "Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
> news:Xns97DC7DAD2FAEBYazorman@.127.0.0.1...|||> Right click on the view
> DO NOT select modify view
> Instead choose Script View as -->ALTER To--> New Query window
This is easily in my top ten of pet peeves in Management Studio. Not just
because Modify does this weird thing with a useless Access-style view
designer that drives me bonkers, but combined with the slowness and the
frequency that I click the wrong menu item, it is maddening.
I was told off the cuff that they're going to add some options to the
immediate right-click menu for views, but I don't know when they'll be
implemented...

Monday, February 13, 2012

Brand New to SQL and Programing

Hi Everyone

I am learning SQL using the "Trial by Fire" method.

The program is based on Pascal and SQL. The database responds to SQL statements. This is a propriety program. The operating system is NT 4.0.

<Problem>
I need to count the number of each type of EnrolStatus for this class.

<Tables Set-Up>
Table Name: Registration
Field Names: EnrolStatus
Field Names: Class_OID

The EnrolStatus is broken down into 4 groups
0=enrolled
1=finished
2=cancelled
3=No Show

The class OID is 1300

<Tried but didn't work>

SELECT * FROM REGISTRATION WHERE REGISTRATION.CLASS_OID = 1300 AND
Recordcount(*) REGISTRATION.EnrolSTATUS = 1

I am hoping someone can help me.

Forgive me if I didn't state everything with the right termsHi mlscw,

To count the number of each type of EnrolStatus of the class. You will need to use the GROUP BY clause and then take the COUNT.

select enrolstatus, count(*)
from registration
where class_oid = 1300
group by enrolstatus

HTH