Click here to Skip to main content
15,902,189 members
Home / Discussions / Database
   

Database

 
AnswerRe: Looking for field name standards documents Pin
Eddy Vluggen2-Jan-10 7:27
professionalEddy Vluggen2-Jan-10 7:27 
QuestionUsing Stored Procedures as a field (SQL Server 2008) Pin
willempipi31-Dec-09 0:34
willempipi31-Dec-09 0:34 
AnswerRe: Using Stored Procedures as a field (SQL Server 2008) Pin
Corporal Agarn31-Dec-09 0:59
professionalCorporal Agarn31-Dec-09 0:59 
GeneralRe: Using Stored Procedures as a field (SQL Server 2008) Pin
willempipi31-Dec-09 1:30
willempipi31-Dec-09 1:30 
GeneralRe: Using Stored Procedures as a field (SQL Server 2008) Pin
Corporal Agarn31-Dec-09 2:27
professionalCorporal Agarn31-Dec-09 2:27 
AnswerRe: Using Stored Procedures as a field (SQL Server 2008) Pin
willempipi31-Dec-09 2:17
willempipi31-Dec-09 2:17 
GeneralRe: Using Stored Procedures as a field (SQL Server 2008) Pin
Corporal Agarn31-Dec-09 2:29
professionalCorporal Agarn31-Dec-09 2:29 
QuestionSQL Server Simultaneous Update with WHERE EXISTS Pin
c0der200930-Dec-09 22:14
c0der200930-Dec-09 22:14 
This is a SQL Server query (I am using SQL Server 2008).

I have an application which runs jobs. I have a JOB table with columns JOB_ID, JOB_STEP etc. When a job is started, an entry is made in this table. When each step is completed, this entry is updated to reflect the next step in JOB_STEP column.

The application is a multi processing application, ie, there are multiple instances of the same application running on multiple servers. All of them read, insert and update into the same database table. (There is only one instance of the DB).

Now, I have a business requirement that no two jobs should be on step 20 (or step 100) together. Ie, if any one job is already on step 20 or 100, all other jobs should wait till that job step is completed.

I have a stored procedure which the application calls to update the step info. I tried something like

update JOB <br />
	set JOB_STEP = @nextStep<br />
	where<br />
	(<br />
		(@nextStep <> '20' AND @nextStep <> '100')<br />
		OR<br />
		(<br />
			(@nextStep = '20' OR @nextStep = '100')<br />
			AND<br />
			NOT EXISTS<br />
(<br />
			select * from LAUNCH_STATISTICS<br />
			where <br />
			(JOB_STEP = '20' OR JOB_STEP = '100')<br />
			and JOB_ID <> @jobId<br />
			)<br />
		)<br />
	)<br />
	and JOB_ID = @jobId;


But it didn’t work. If jobs try to change steps one after the other, this works. But if I call this SP from two different processes at the same time, both of them manage to end up with Step 20 (or 100) sometimes.
Please help me in finding out what I am missing.

I tried with different TRANSACTION_ISOLATION levels but it didn't help.
AnswerRe: SQL Server Simultaneous Update with WHERE EXISTS Pin
c0der200930-Dec-09 23:51
c0der200930-Dec-09 23:51 
QuestionConnection string loaded from config file Pin
Nigel Mackay30-Dec-09 18:44
Nigel Mackay30-Dec-09 18:44 
AnswerRe: Connection string loaded from config file Pin
Eddy Vluggen31-Dec-09 4:59
professionalEddy Vluggen31-Dec-09 4:59 
GeneralRe: Connection string loaded from config file Pin
Nigel Mackay31-Dec-09 19:32
Nigel Mackay31-Dec-09 19:32 
QuestionSQL Server 2005 Express edition Registration. Pin
TinyDevices30-Dec-09 1:41
professionalTinyDevices30-Dec-09 1:41 
AnswerRe: SQL Server 2005 Express edition Registration. Pin
Andy_L_J30-Dec-09 3:23
Andy_L_J30-Dec-09 3:23 
GeneralRe: SQL Server 2005 Express edition Registration. Pin
TinyDevices30-Dec-09 19:32
professionalTinyDevices30-Dec-09 19:32 
AnswerRe: SQL Server 2005 Express edition Registration. Pin
Eddy Vluggen30-Dec-09 6:04
professionalEddy Vluggen30-Dec-09 6:04 
GeneralRe: SQL Server 2005 Express edition Registration. Pin
TinyDevices30-Dec-09 19:34
professionalTinyDevices30-Dec-09 19:34 
QuestionRe: SQL Server 2005 Express edition Registration. Pin
Eddy Vluggen31-Dec-09 5:02
professionalEddy Vluggen31-Dec-09 5:02 
QuestionC# SQL express Login Pin
kadaen29-Dec-09 22:56
kadaen29-Dec-09 22:56 
AnswerRe: C# SQL express Login Pin
nagendrathecoder29-Dec-09 23:18
nagendrathecoder29-Dec-09 23:18 
GeneralRe: C# SQL express Login Pin
kadaen29-Dec-09 23:25
kadaen29-Dec-09 23:25 
GeneralRe: C# SQL express Login Pin
nagendrathecoder29-Dec-09 23:33
nagendrathecoder29-Dec-09 23:33 
GeneralRe: C# SQL express Login Pin
kadaen29-Dec-09 23:43
kadaen29-Dec-09 23:43 
GeneralRe: C# SQL express Login Pin
nagendrathecoder29-Dec-09 23:44
nagendrathecoder29-Dec-09 23:44 
GeneralRe: C# SQL express Login Pin
kadaen29-Dec-09 23:54
kadaen29-Dec-09 23:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.