Showing posts with label lines. Show all posts
Showing posts with label lines. Show all posts

Wednesday, March 28, 2012

Numbering the SQL Query statements

Using the TOAD application for Oracle, I am able to number the SQL query lines for readability. Can the same be done for SQL Server 2005?

Hi,

I think you mean in SQL Server Management Studio.
This is possible by performing the following steps:

In SQL Server Management Studio go to Tools\Options|||

Yes... In Server Management Studio, choose Options from the menu bar.

Expand "Text Editor", Expand "All Languages" and click on General

Under "Display", check the "Line Numbers" box...

sql

Numbering Lines (Ranking)

I have a report that show all of are salesmen sorted by the number of sales they have. What I have been asked to do is to give them an actual ranking (Number 1, Number 2 etc...). Being fairly new to SQL I am not sure how to do this so here I am.

Thank you for any help that anyone can give me.

You can use RowNumber(Nothing). Check out the docs for more info.

|||Thank you for the help.

Monday, March 26, 2012

number rows

I have wrote a query that returns product details for all orders that are at stage 6. Is there a way to number the product lines in each order no?!

Eg.
Order 1
Product 1 - 1
Product 2 - 2
Product 3 - 3

--counter restarts
Order 2
Product 1 - 1
Product 2 -2

thanks?If you are using SQL 2005, you could look into using the ROW_NUMBER function with the PARTITION BY option.|||Or you can just let the front end do it..or insert the rows into a temp table with an identity column then select from that

Wednesday, March 21, 2012

Number of lines of code in a SP

Hi,
How to find out the total number of lines in a stored proc programmatically?
Regards
Pradeepselect
sum(len(replace(sc.text, ' ', '_')) - len(replace(replace(sc.text, ' ', '_')
, char(13), ''))) + 1
from sysobjects so
inner join syscomments sc on
so.id = sc.id
where
name = 'myStoredProc'|||I assume this was not a question or am I wrong. And why would you be
interested in the number of lines. If you change the formatting, the
number of lines might change, but the SP is till doing the same ?
Markus|||> And why would you be
> interested in the number of lines.
I can't speak for the OP, but the number procedure lines can be a rough
indicator of application complexity. These kind of metrics can be useful in
estimating development effort for major changes, such as a rewrite or
conversion.
Hope this helps.
Dan Guzman
SQL Server MVP
<m.bohse@.quest-consultants.com> wrote in message
news:1133867063.700631.79970@.g49g2000cwa.googlegroups.com...
>I assume this was not a question or am I wrong. And why would you be
> interested in the number of lines. If you change the formatting, the
> number of lines might change, but the SP is till doing the same ?
> Markus
>|||Thats right Dan. I need it for metrics purpose only.
Regards
Pradeep
"Dan Guzman" wrote:

> I can't speak for the OP, but the number procedure lines can be a rough
> indicator of application complexity. These kind of metrics can be useful
in
> estimating development effort for major changes, such as a rewrite or
> conversion.
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> <m.bohse@.quest-consultants.com> wrote in message
> news:1133867063.700631.79970@.g49g2000cwa.googlegroups.com...
>
>|||Could this be easily extended to get the lengths of all stored
procedures in a db?
"daw" <murmax@.rambler.ru> wrote:

>select
> sum(len(replace(sc.text, ' ', '_')) - len(replace(replace(sc.text, ' ', '
_'), char(13), ''))) + 1
>from sysobjects so
> inner join syscomments sc on
> so.id = sc.id
>where
> name = 'myStoredProc'
>|||On Sat, 10 Dec 2005 14:36:24 GMT, John Baima wrote:

>Could this be easily extended to get the lengths of all stored
>procedures in a db?
Hi John,
Length in lines, you mean?
Try
select
name,
sum(len(replace(sc.text, ' ', '_')) - len(replace(replace(sc.text, '
', '_'), char(13), ''))) + 1
from sysobjects so
inner join syscomments sc on
so.id = sc.id
group by
name
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)