Showing posts with label t-sql. Show all posts
Showing posts with label t-sql. Show all posts

Friday, March 23, 2012

Monthname in SQL server

Being new to SQL server T-SQL (working with DB2 / ORACLE) is there a function like monthname() in SQL server. I.e. a function that takes date as input and returns the Monthname (like AUG or AUGUST)??This example extracts the month name from the date returned by GETDATE.

SELECT DATENAME(month, getdate()) AS 'Month Name'

Here is the result set:

Month Name
----------
February|||Sorry, where can I put the date where I can extract the monthname from?
I want to add an object that displays 'JAN' or Januari if I have a date like:
01/01/2003|||SELECT DATENAME(month, '01/01/2003') AS 'Month Name'|||Thank you very much..............

Monday, February 20, 2012

Momitoring when job has executed

Is there a technique for determining when a job has been executed - using T-SQL? I tried using 'sp_help_job' by inserting the output into a table (e.g. INSERT jobtable EXEC sp_help_job...) but I get the following error:

Msg 8164, Level 16, State 1, Procedure sp_get_composite_job_info, Line 68

An INSERT EXEC statement cannot be nested.

Any ideas anyone?

Rgds

Bertrand

You can all the info from msdb..sysjobs and msdb..sysjobsteps table. I suggest you take a look at the following article (thanks Gert) so you can handle the sqlagent datetime.
http://sqldev.net/sqlagent/SQLAgentDateTime.htm