Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Not generating run time


Not generating run time

Author
Message
dwilliscp
dwilliscp
SSC-Addicted
SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)

Group: General Forum Members
Points: 420 Visits: 767
I have the SQL, listed below, what I would like to do is to get the fractions down to two places (0.25), but looking at the convert function it looks like the min is 6. Any ideas?

set @message = 'time ' + cast((cast(datediff(ss,@startdate,getdate()) as int)/60) as varchar(12))
Sean Lange
Sean Lange
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16582 Visits: 17024
dwilliscp (11/5/2012)
I have the SQL, listed below, what I would like to do is to get the fractions down to two places (0.25), but looking at the convert function it looks like the min is 6. Any ideas?

set @message = 'time ' + cast((cast(datediff(ss,@startdate,getdate()) as int)/60) as varchar(12))



Like this?

select 'time ' + cast(cast(cast(datediff(ss,@startDate - 1,getdate()) as int)/60. as numeric(9,2)) as varchar(15))



_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
menon.satyen
menon.satyen
SSC Rookie
SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)

Group: General Forum Members
Points: 25 Visits: 230
Hi,

what is your @startdate datatype.

Also can you give an example on what the parameters actual value are and what you want it to look like.

Thanks
Satyen


sorry didnt see the reply.
good work!!!
dwilliscp
dwilliscp
SSC-Addicted
SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)

Group: General Forum Members
Points: 420 Visits: 767
It is datetime..

declare @startdate datetime

and I am using getdate() to load into @startdate, at the top of the program.

So I would expect to see ... lets say the program took 28min , I would expect to see the following:

time 0.25 time 0.40 time 1.50 time 6.33 time 9.75 time 13.12 time 25.05 time 26.80 time 28.0

Note my code has a label before time, so I know what statement was last executed.
dwilliscp
dwilliscp
SSC-Addicted
SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)

Group: General Forum Members
Points: 420 Visits: 767
Oh, and I am also using @@rowcount to show the number of records. After this things will get a bit interesting.. since I will have to capture things that would cause the statement to take a lot longer to run. The program in question runs fine most of the month, but about three days a month it spikes and runs about four times as long. I am writing the @message, and the job name, into a table so I can capture the normal and spikes.. and I hope to find out why it spikes.
dwilliscp
dwilliscp
SSC-Addicted
SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)

Group: General Forum Members
Points: 420 Visits: 767
Thanks Sean, I use the numeric data type so seldom I often forget about it. (I tend to use float or one of the int)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search