Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

how to combine and convert two integer columns to datetime Expand / Collapse
Author
Message
Posted Monday, March 18, 2013 2:38 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 4:52 PM
Points: 7,079, Visits: 12,569
ChrisM@Work (3/18/2013)
opc.three (3/15/2013)
PS Forgot to mention the function is undocumented so take that into consideration.

It's a cough scalar function too.

Meh. We're talking about SQL Agent data so IMHO it's not something to get in a twist over (or even having a cough over)


__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1432341
Posted Monday, March 18, 2013 2:57 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 10:01 PM
Points: 22,980, Visits: 31,456
opc.three (3/18/2013)
ChrisM@Work (3/18/2013)
opc.three (3/15/2013)
PS Forgot to mention the function is undocumented so take that into consideration.

It's a cough scalar function too.

Meh. We're talking about SQL Agent data so IMHO it's not something to get in a twist over (or even having a cough over)


Actually, the OP never did say if it was SQL Agent data that he was working with here. It could actually be data in his application database.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1432353
Posted Monday, March 18, 2013 3:58 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 4:52 PM
Points: 7,079, Visits: 12,569
Lynn Pettis (3/18/2013)
opc.three (3/18/2013)
ChrisM@Work (3/18/2013)
opc.three (3/15/2013)
PS Forgot to mention the function is undocumented so take that into consideration.

It's a cough scalar function too.

Meh. We're talking about SQL Agent data so IMHO it's not something to get in a twist over (or even having a cough over)


Actually, the OP never did say if it was SQL Agent data that he was working with here. It could actually be data in his application database.

Well, gee, I was thinking that was implied given the format of the data and was validated by the fact that the OP latched onto the msdb proc when replying directly to me, but you have a valid point. He could have been talking about data in an application database, or come to think of it, he could also have a shedload of historical data in his SQL Agent history tables but that would likely point to job-history maintenance issue.

@naveen.pasupuleti, could you tell us if you're applying this to SQL Agent data stored in msdb, or some other type of data source where you could be evaluating a non-trivial number of rows?


__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1432372
Posted Tuesday, March 19, 2013 11:21 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, July 18, 2014 1:00 PM
Points: 178, Visits: 215
It is an application database used for reporting purposes, where I need to calculate datetime out of two integer columns (till last week, I calculated only date but new requirement asks for date and time). However, these int columns get data from msdb.dbo.sysjobservers as source table.
This function msdb.dbo.agent_datetime(@int1, @int2) is helpful for me in both ways:
1. I applied for my immediate reporting purposes
2. I added a datetime column in my table, updated column for current data and used this function in SSIS package.

All solutions are good but built-in function is new learning & quick for me.
I appreciate each of you for your responses.

Thanks,
Naveen.
Post #1432801
Posted Tuesday, March 19, 2013 11:47 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 4:52 PM
Points: 7,079, Visits: 12,569
OK, SQL Agent data, that's good, the use case fits, but you're repurposing it so how much data are we talking about? For managing SQL Agent historical data the scalar-function is fine because the volume is limited (if the instance is configured well) but if we're talking about a non-trivial amount of data you should consider switching to a home-made table-valued function instead. It will scale much better and not use anywhere near as much CPU.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1432824
Posted Tuesday, March 19, 2013 12:57 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, July 18, 2014 1:00 PM
Points: 178, Visits: 215
Weekly once ~800 records. It should ok to use function at the moment.
Yes, I would consider using TVF if data is significant.
Post #1432862
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse