Rob Bamforth's Blog
Java, SQL,T-SQL, MySQL, Networking, SQL Server, PHP, COM, DBA, ODBC

Archive for July, 2009

How to Disable Or Enable SQL Server Jobs Programmatically

July 31, 2009

The following 2 methods show how to enable / disable and SQL server agent jobs programmatically.
To Enable a Job: 
UPDATE
 MSDB.dbo.sysjobs
SET
    Enabled = 1
WHERE Name = ‘JOB_NAME’;
To Disable a Job: 
UPDATE
 MSDB.dbo.sysjobs
SET
    Enabled = 0
WHERE Name = ‘JOB_NAME’;

SQL – Check If One String Contains Another String (CHARINDEX)

July 28, 2009

The CHARINDEX() function returns the location of a search string within another string.
For Example:  
This code will return 8, which equates to the position of ’sentance’ within the string ‘This is a sentance’.
select charindex(’sentance’,’This is a sentance’) 
This can be used to check if string A is contained in String B by using the following command:
select * from [...]