Showing posts with label tasks. Show all posts
Showing posts with label tasks. Show all posts

Tuesday, March 20, 2012

Repetitive SQL Tasks

Thanks in advance.

I am new to sql script area.

Below is my ugly program.

Help, please)

There should be a better code to handle these repetitive tasks.

/* DECLARE Part Omitted */

SET @.Job_Code_A = '(Job_Type = ''A'')';

SET @.Job_Code_B = '(Job_Type = ''B'')';

.... And so on

SET @.SQL1 = 'Select Count(*) FROM tblWorkorders WHERE' + @.Job_Code_A;

SET @.SQL2 = 'Select Count(*) FROM tblWorkorders WHERE' + @.Job_Code_B;

..... And so on

EXEC (@.SQL1);

EXEC (@.SQL2);

..... And so on

Why do you need dynamic SQL? You can do:

select o.Job_Type, count(*)

from tblWorkOrders as o

where o.Job_Type in ('A', 'B')

group by o.Job_Type;

|||

Thank you for reply.

I need to use three-level depth loops from outer conditions.

Wednesday, March 7, 2012

Repairing 'The shared data source reference is no longer valid' is long winded in report m

Would be great to be able to multi select reports in report manager and set data sources etc. as tasks like that take a long time when done individually.

Yes, that would be a nice feature.

You might consider using RS.exe scripts if you have to do this for lots of reports, or for a few reports on a regular basis.

Saturday, February 25, 2012

Reorganize data and index pages

Hello all,

SQL 2000 on Windows 2000. If I go into all tasks, maintenance plan, it
gives me an option to reorganize data and index pages. When I check on
it, it populates the line "change free space per page percentage to" and
puts in 10 in there. Is this the default for free space? Is it the
data pages that will have 10% free space or just the index pages? Are
data and index on the same pages?

Thanks,
Raziq.

*** Sent via Developersdex http://www.developersdex.com ***Hi

If you profile the maintainance plan is seems that choosing causes a call to
DBCC DBREINDEX which is documented in books online. The 10% free space value
is reversed to be a 90% fillfactor as described by:

fillfactor
Is the percentage of space on each index page to be used for storing data
when the index is created. fillfactor replaces the original fillfactor as
the new default for the index and for any other nonclustered indexes rebuilt
because a clustered index is rebuilt. When fillfactor is 0, DBCC DBREINDEX
uses the original fillfactor specified when the index was created.

If you look at the Table and Index Architecture section of books online you
will see how clustered and non-clustered indexes are composed.
or at:
http://msdn.microsoft.com/library/d...ar_da2_8sit.asp
http://msdn.microsoft.com/library/d...ar_da2_1tbn.asp
http://msdn.microsoft.com/library/d...ar_da2_75mb.asp

You may want to get "Inside SQL Server 2000" by Kalen Delany ISBN
0-7356-0998-5 which talks about this sort of thing in detail.

John

"Raziq Shekha" <raziq_shekha@.anadarko.com> wrote in message
news:rF97e.5$Nk2.347@.news.uswest.net...
> Hello all,
> SQL 2000 on Windows 2000. If I go into all tasks, maintenance plan, it
> gives me an option to reorganize data and index pages. When I check on
> it, it populates the line "change free space per page percentage to" and
> puts in 10 in there. Is this the default for free space? Is it the
> data pages that will have 10% free space or just the index pages? Are
> data and index on the same pages?
> Thanks,
> Raziq.
>
> *** Sent via Developersdex http://www.developersdex.com ***