Friday, March 30, 2012
profiler
I need to gather user activities on our SQL2K server on
weekdays between 8-5 using the profiler. Is there a way to
schedule this to start and stop at these times?
Thanks,
Mark
You can create and start traces using TSQL scripts. You get a handle back with which you can stop
and close a trace. Easiest way to get started is to define the trace in Profiler, and from the
profiler menu save the trace definition as a TSQL script.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"mark" <anonymous@.discussions.microsoft.com> wrote in message
news:067d01c51055$dd11e810$a501280a@.phx.gbl...
> Hi
> I need to gather user activities on our SQL2K server on
> weekdays between 8-5 using the profiler. Is there a way to
> schedule this to start and stop at these times?
> Thanks,
> Mark
Wednesday, March 28, 2012
profiler
I need to gather user activities on our SQL2K server on
weekdays between 8-5 using the profiler. Is there a way to
schedule this to start and stop at these times?
Thanks,
MarkYou can create and start traces using TSQL scripts. You get a handle back wi
th which you can stop
and close a trace. Easiest way to get started is to define the trace in Prof
iler, and from the
profiler menu save the trace definition as a TSQL script.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"mark" <anonymous@.discussions.microsoft.com> wrote in message
news:067d01c51055$dd11e810$a501280a@.phx.gbl...
> Hi
> I need to gather user activities on our SQL2K server on
> weekdays between 8-5 using the profiler. Is there a way to
> schedule this to start and stop at these times?
> Thanks,
> Marksql
Monday, March 26, 2012
Producing week ending dates for each week of the year
I am trying to produce a script that will show date for the last day of the week(Sunday). The script will have to show dates for all weeks of the year. Does anyone know how this can be done?
Thanks
Quote:
Originally Posted by rcr69er
Hi
I am trying to produce a script that will show date for the last day of the week(Sunday). The script will have to show dates for all weeks of the year. Does anyone know how this can be done?
Thanks
hai try this-----------
declare
v_date date;
begin
select next_day('01-JAN-07','sunday') into v_date from dual;
for i in 0..51 loop
dbms_output.put_line(to_char(to_date((v_date)+7*i) ));
end loop;
end;sql
Friday, March 23, 2012
Produce data -> Store in table?
I'm quite new to T-SQL and is about to build a small reporting db using SQL.
Most of the data I can move with normal INSERT INTO ... SELECT, but there are some tables that I want to
produce using T-SQL. For example I want to build a Date table like..
Date
Year
Quarter
Month
WeekDay
...
With some precalculated values for each date.
I've searched the forum but have not found any information on how to produce table contents in a good manner. I would appreciate if someone would have the time to point me in the right direction. I do not want to do this by code in my application.
My first thought is to use some kind of Insert Cursor in a While loop...
Pseudo:
declare cursor ex for 'Insert table ... '
while
begin
(produce data)
insert data
close cursor
While browsing the net I've got the feeling that you use cursor less in SQL Server than in other db-engines...
Have a nice day!
You could use WHILE loop without cursor:
Code Snippet
create table dates
(
Year int,
Quarter int,
Month int,
WeekDay int,
SomeData decimal
)
go
declare @.start_date datetime
declare @.end_date datetime
set @.start_date = '2007-01-01'
set @.end_date = getdate()
while @.start_date<@.end_date
begin
set @.start_date = dateadd(day, 1, @.start_date)
insert into dates values(
datepart(year,@.start_date),
datepart(quarter,@.start_date),
datepart(month,@.start_date),
datepart(weekday,@.start_date),
rand() --Just for demo
)
end
go
select * from Dates
|||Best have a calendar table (you can add all the nessasary columns here), fill the table with required date range, join with your table & use the required calculations,
Code Snippet
create table calendar
(
year int,
quarter int,
month int,
weekday int,
date datetime primary key
)
Go
create proc fill_calendar(@.start_date datetime,@.end_date datetime)
as
begin
set nocount on;
while @.start_date <= @.end_date
begin
insert into calendar
select
datepart(year,@.start_date),
datepart(quarter,@.start_date),
datepart(month,@.start_date),
datepart(weekday,@.start_date),
@.start_date
where
not exists(select 1 from calendar where date=@.start_date);
set @.start_date = dateadd(day, 1, @.start_date)
end
end
go
--Fill your calendar when required
exec fill_calendar '1/1/2000','12/31/2007'
select * from calendar
go
select
year --other columns
,sum(yourtable.calculation)
from
calendar
inner join yourtable on yourtable.datefield = calendar.date
group by
year --other columns
Wednesday, March 21, 2012
Processor Utilization
I am running SQL Server 2000 on a 2 processor system (Windows 2003
Standard). I regularily run large queries. When I run the queries the CPU
utilization is consitantly around 11%.
It appears as if something is limiting SQL Server to 11% CPU per
process/query. I have verified that its not I/O bound.
The Processor properties are set as follows:
- All 2 processors are checked in Processor Control
- "Maximum worker threads" is set to 255
- "Boost SQL Server priority on Windows" is not checked
- "Use Windows NT fibres" is checked
- "Use all available processors" is checked
Why is the CPU not fully utilized? What does "Boost SQL Server priority on
Windows" do?
Any assistance would be greatly appreciated
Thanks
Hi
You may want to check the boost priority option and not use fibres (as
fibres can cause other problems). You could also try using the MAXDOP hint to
only use one processor.
Monitor context switches to see if there is an excessive number before
considering using fibres. Ken Hendersons book The Gurus Guide to SQL Server
Architecture and Internals ISBN 0201700476 has a good section on this.
John
"Macisu" wrote:
> Hi
> I am running SQL Server 2000 on a 2 processor system (Windows 2003
> Standard). I regularily run large queries. When I run the queries the CPU
> utilization is consitantly around 11%.
> It appears as if something is limiting SQL Server to 11% CPU per
> process/query. I have verified that its not I/O bound.
> The Processor properties are set as follows:
> - All 2 processors are checked in Processor Control
> - "Maximum worker threads" is set to 255
> - "Boost SQL Server priority on Windows" is not checked
> - "Use Windows NT fibres" is checked
> - "Use all available processors" is checked
> Why is the CPU not fully utilized? What does "Boost SQL Server priority on
> Windows" do?
> Any assistance would be greatly appreciated
> Thanks
Processor Utilization
I am running SQL Server 2000 on a 2 processor system (Windows 2003
Standard). I regularily run large queries. When I run the queries the CPU
utilization is consitantly around 11%.
It appears as if something is limiting SQL Server to 11% CPU per
process/query. I have verified that its not I/O bound.
The Processor properties are set as follows:
- All 2 processors are checked in Processor Control
- "Maximum worker threads" is set to 255
- "Boost SQL Server priority on Windows" is not checked
- "Use Windows NT fibres" is checked
- "Use all available processors" is checked
Why is the CPU not fully utilized? What does "Boost SQL Server priority on
Windows" do?
Any assistance would be greatly appreciated
ThanksHi
You may want to check the boost priority option and not use fibres (as
fibres can cause other problems). You could also try using the MAXDOP hint t
o
only use one processor.
Monitor context switches to see if there is an excessive number before
considering using fibres. Ken Hendersons book The Gurus Guide to SQL Server
Architecture and Internals ISBN 0201700476 has a good section on this.
John
"Macisu" wrote:
> Hi
> I am running SQL Server 2000 on a 2 processor system (Windows 2003
> Standard). I regularily run large queries. When I run the queries the CPU
> utilization is consitantly around 11%.
> It appears as if something is limiting SQL Server to 11% CPU per
> process/query. I have verified that its not I/O bound.
> The Processor properties are set as follows:
> - All 2 processors are checked in Processor Control
> - "Maximum worker threads" is set to 255
> - "Boost SQL Server priority on Windows" is not checked
> - "Use Windows NT fibres" is checked
> - "Use all available processors" is checked
> Why is the CPU not fully utilized? What does "Boost SQL Server priority on
> Windows" do?
> Any assistance would be greatly appreciated
> Thanks
Tuesday, March 20, 2012
Processing the TEXT datatype with TSQL
I have a table with a TEXT datatype.
Its a comment field.
Right now the users who put in singlequotes are killing the web front
end.
The programmer responsible is fixing this issue but it might be a few
weeks until we get the patch.
I would like to write a trigger that whenever this field is updated it
will scan the text for single quotes ( and hard returns \r ) and
extract them.
I found some nice string functions in HELP.
Will these string functions work with the TEXT datatype in a TSQL
script/trigger?
Thanks in advance
SteveI handle quotes with the REPLACE function. All languages that I work with
has it.
Two single quotes in a row signify an escape sequence from the normal
interpretation of the single quote character. When two single quotes appear
together, they are interpreted by SQL as one literal single quote. All we
need do, then, is replace any single quote with two single quotes in strings
that we want interpreted literally by SQL.
This won't work on a Text datatype, however it does work on varchars and
stuff. Check your max len() on that field and see if it actually is using
more than the capacity of other datatypes and see about changing it to
varchar or something. This t-sql replaces one quote with two and would save
your web person endless hours of javascript'ing validation code!!
Select REPLACE(testColumn, char(39), char(39) + char(39)) as texta from
myTable
After all, quotes are valid characters too!!!
Good luck!
--
Jerry Boone
Analytical Technologies, Inc.
http://www.antech.biz
"Steve" <stevesusenet@.yahoo.com> wrote in message
news:6f8cb8c9.0311140657.59346a15@.posting.google.c om...
> Hi;
> I have a table with a TEXT datatype.
> Its a comment field.
> Right now the users who put in singlequotes are killing the web front
> end.
> The programmer responsible is fixing this issue but it might be a few
> weeks until we get the patch.
> I would like to write a trigger that whenever this field is updated it
> will scan the text for single quotes ( and hard returns \r ) and
> extract them.
> I found some nice string functions in HELP.
> Will these string functions work with the TEXT datatype in a TSQL
> script/trigger?
> Thanks in advance
> Steve
Friday, March 9, 2012
Processed Date for a Cube
Hi
I want to be able to display to the users the date/time a cube was last processed. We have SSAS 2005 and presenting the cube through Excel 2003 (with the SSAS 9 OLAP driver).
Thanks
LastProcessed is a property on the object avaliable only through AMO. Dont think Excel will show you this property.
You can possible wirte a AMO code yourself and use Excel programming model to show it.
Another way is to create a dimension with a single memeber based on the column in the relational database where you would keep the current date and during processing you update this dimension to pickup a new value.
Edward.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Thanks for the suggestions.
I created a table with the current date and use this.
Wednesday, March 7, 2012
process result recordset from storedproc
I have a stored proc which aggregates some values and
returns a recordset with one record
...looking something like this:
val1 val2 val3
-- -- --
24723 26457 342579
how can I use this record for further processing
e.g. write it into an existing table (for logging)
hmm, this is probably a newbie-question
but I couldnt find the answer in BOL...
any help is greatly appreciated,
best regards,
haraldIf you want to handle only one record you can use variables to store and use
it.
For eg:
Declare @.Val1 int , @.Val2 int ...
Select @.Val1 = Val1, @.Val2 = Val2 etv...
Insert into TableName (@.Val1, @.val2 etc..
Other wise you can use a cursor for looping it.
Please refer books online.
Thank you
Baiju
"Harald Peki" <mabuse007@.yahoo.com> wrote in message
news:1109832522.363076@.news.liwest.at...
> hi!
> I have a stored proc which aggregates some values and
> returns a recordset with one record
> ...looking something like this:
> val1 val2 val3
> -- -- --
> 24723 26457 342579
> how can I use this record for further processing
> e.g. write it into an existing table (for logging)
>
> hmm, this is probably a newbie-question
> but I couldnt find the answer in BOL...
> any help is greatly appreciated,
> best regards,
> harald
>
>|||hello baiju,
thanks very much - I am aware of cursors, but hoped there would be a
easier and more elegant solution.
generally asked: isnt there a way to use the storedproc-recordset in the
same
way like the resultset of a function which returns a table?
I this case I can use a statement like this:
INSERT INTO StatsTables
SELECT * FROM dbo.adm_CountAllTables_function()
...where dbo.adm_CountAllTables_function() is - obviously ;))) - a
function...
hmm, I guess it IS the most usefull solution to change the storedproc to a
function.
Im most thankful for any further comments.
best regards,
harald
"Baiju" <baiju@.indus-systems.com> schrieb im Newsbeitrag
news:uhfN$f8HFHA.4032@.TK2MSFTNGP12.phx.gbl...
> If you want to handle only one record you can use variables to store and
use
> it.
> For eg:
> Declare @.Val1 int , @.Val2 int ...
> Select @.Val1 = Val1, @.Val2 = Val2 etv...
> Insert into TableName (@.Val1, @.val2 etc..
>
> Other wise you can use a cursor for looping it.
> Please refer books online.
>
> Thank you
> Baiju
>
> "Harald Peki" <mabuse007@.yahoo.com> wrote in message
> news:1109832522.363076@.news.liwest.at...
>|||use
insert into table_name
exec proc_name
"Harald Peki" wrote:
> hi!
> I have a stored proc which aggregates some values and
> returns a recordset with one record
> ...looking something like this:
> val1 val2 val3
> -- -- --
> 24723 26457 342579
> how can I use this record for further processing
> e.g. write it into an existing table (for logging)
>
> hmm, this is probably a newbie-question
> but I couldnt find the answer in BOL...
> any help is greatly appreciated,
> best regards,
> harald
>
>|||hi tom!
> insert into table_name
> exec proc_name
oops! great!!!
...but funny...tried that one but obviously had some syntax mistake or
something...
WORKS GREAT NOW!!
Thanks very, very much!
all systems up and running ;))
best regards,
harald
"Tomasz Borawski" <TomaszBorawski@.discussions.microsoft.com> schrieb im
Newsbeitrag news:4895E3C4-C967-46BB-99F4-54724C98CE71@.microsoft.com...
> use
> insert into table_name
> exec proc_name
>
> "Harald Peki" wrote:
>
Saturday, February 25, 2012
Process Cube using SQL DTS
I have created a package to do this which simply returns with the error
'1 task(s) failed during execution'. I can process the dimensions and
cubes manually in analysis Manager fine.
SQL and analysis Manager are both on the same server and the task
appears to be running with the domain administrator user.
Cany anyone help?
Cheers
Brettos.
brettos
Posted via http://www.webservertalk.com
View this thread: http://www.webservertalk.com/message542345.html
In workflow properties, set "Execute on main package thread", including all
packages that contains OLAP processing.
James Ma
"brettos" wrote:
> Hi
> I have created a package to do this which simply returns with the error
> '1 task(s) failed during execution'. I can process the dimensions and
> cubes manually in analysis Manager fine.
> SQL and analysis Manager are both on the same server and the task
> appears to be running with the domain administrator user.
> Cany anyone help?
> Cheers
> Brettos.
>
> --
> brettos
> Posted via http://www.webservertalk.com
> View this thread: http://www.webservertalk.com/message542345.html
>
|||To help in your debuging.
Open The package in design mode.
Right Click and Select "Package Properties"
Select The "Logging" tab.
Provide a log file location to use during processing of the package.
save and close the package.
Now run the package.
Open the log file and see what details you can gleam.
report back to us.
Hope this helps.
dlr
"brettos" <brettos.1gk5p2@.mail.webservertalk.com> wrote in message
news:brettos.1gk5p2@.mail.webservertalk.com...
> Hi
> I have created a package to do this which simply returns with the error
> '1 task(s) failed during execution'. I can process the dimensions and
> cubes manually in analysis Manager fine.
> SQL and analysis Manager are both on the same server and the task
> appears to be running with the domain administrator user.
> Cany anyone help?
> Cheers
> Brettos.
>
> --
> brettos
> Posted via http://www.webservertalk.com
> View this thread: http://www.webservertalk.com/message542345.html
>
Process Cube using SQL DTS
I have created a package to do this which simply returns with the error '1 t
ask(s) failed during execution'. I can process the dimensions and cubes man
ually in analysis Manager fine.
SQL and analysis Manager are both on the same server and the task appears to
be running with the domain administrator user.
Cany anyone help?
Cheers
Brettos.In workflow properties, set "Execute on main package thread", including all
packages that contains OLAP processing.
James Ma
"brettos" wrote:
> Hi
> I have created a package to do this which simply returns with the error
> '1 task(s) failed during execution'. I can process the dimensions and
> cubes manually in analysis Manager fine.
> SQL and analysis Manager are both on the same server and the task
> appears to be running with the domain administrator user.
> Cany anyone help?
> Cheers
> Brettos.
>
> --
> brettos
> ---
> Posted via http://www.webservertalk.com
> ---
> View this thread: http://www.webservertalk.com/message542345.html
>|||To help in your debuging.
Open The package in design mode.
Right Click and Select "Package Properties"
Select The "Logging" tab.
Provide a log file location to use during processing of the package.
save and close the package.
Now run the package.
Open the log file and see what details you can gleam.
report back to us.
Hope this helps.
dlr
"brettos" <brettos.1gk5p2@.mail.webservertalk.com> wrote in message
news:brettos.1gk5p2@.mail.webservertalk.com...
> Hi
> I have created a package to do this which simply returns with the error
> '1 task(s) failed during execution'. I can process the dimensions and
> cubes manually in analysis Manager fine.
> SQL and analysis Manager are both on the same server and the task
> appears to be running with the domain administrator user.
> Cany anyone help?
> Cheers
> Brettos.
>
> --
> brettos
> ---
> Posted via http://www.webservertalk.com
> ---
> View this thread: http://www.webservertalk.com/message542345.html
>