Click here to Skip to main content
15,895,370 members
Home / Discussions / Database
   

Database

 
QuestionSQL Server CE : How to create a database from C++ with ADO Pin
Leif Goodwin26-Oct-10 2:11
Leif Goodwin26-Oct-10 2:11 
AnswerRe: SQL Server CE : How to create a database from C++ with ADO => SOLVED Pin
Leif Goodwin26-Oct-10 3:33
Leif Goodwin26-Oct-10 3:33 
QuestionField ordering in a table Pin
john john mackey25-Oct-10 7:10
john john mackey25-Oct-10 7:10 
AnswerRe: Field ordering in a table Pin
J4amieC25-Oct-10 21:21
J4amieC25-Oct-10 21:21 
AnswerRe: Field ordering in a table Pin
i.j.russell25-Oct-10 23:32
i.j.russell25-Oct-10 23:32 
AnswerRe: Field ordering in a table Pin
Mycroft Holmes26-Oct-10 3:04
professionalMycroft Holmes26-Oct-10 3:04 
GeneralRe: Field ordering in a table Pin
Gerben Jongerius26-Oct-10 3:41
Gerben Jongerius26-Oct-10 3:41 
QuestionSQL Server Trigger [modified] Pin
Jay Royall25-Oct-10 5:03
Jay Royall25-Oct-10 5:03 
Hi,

Scenario:
I have a database which is going to be replicated via a set of web services. The web services will select all records where [AwaitingSync] = true. I have cerated two triggers for each table which sets [AwaitingSync] to true when a record is inserted or updated. The web service then sets [AwaitingSync] to false for all records.

Problem:
Due to a combination of my inexperience and lack of thought there is a slight problem(you'ver probably already noticed what the problem is!). After synching, when the web service sets [AwaitingSync] to false the update trigger fires and sets it back to true! D'Oh! | :doh:

My question is this then; what can I do about this? Can I add a conditional statement to the trigger so that it only fires if a particular column is being updated(or not being updated in this case). Or maybe the trigger be temporarily disabled while the [AwaitingSync] column is being updated. Or are there any other solutions to this?

Thanks for your time.

EDIT: Think I've found a solution but I would still appreciate your views if there is a better way of doing this. I have modified the trigger to check the value of [AwaitingSync] before updating.
IF(SELECT [AwaitingSync] FROM DELETED) = 0
	BEGIN		
		UPDATE	tblProductCategories
		SET		[DateModified] = GetDate(),
				[AwaitingSync] = 1
		WHERE	[ID] = (SELECT [ID] FROM INSERTED)
	END


modified on Monday, October 25, 2010 11:21 AM

AnswerRe: SQL Server Trigger Pin
Chris Meech25-Oct-10 6:13
Chris Meech25-Oct-10 6:13 
GeneralRe: SQL Server Trigger Pin
Jay Royall25-Oct-10 22:20
Jay Royall25-Oct-10 22:20 
GeneralRe: SQL Server Trigger Pin
Chris Meech26-Oct-10 2:38
Chris Meech26-Oct-10 2:38 
QuestionSimple question from new sql server user ... [modified] Pin
Yanshof25-Oct-10 2:25
Yanshof25-Oct-10 2:25 
AnswerRe: Simple question from new sql server user ... Pin
PIEBALDconsult25-Oct-10 3:34
mvePIEBALDconsult25-Oct-10 3:34 
GeneralRe: Simple question from new sql server user ... Pin
NeverHeardOfMe25-Oct-10 4:18
NeverHeardOfMe25-Oct-10 4:18 
GeneralRe: Simple question from new sql server user ... Pin
PIEBALDconsult25-Oct-10 9:22
mvePIEBALDconsult25-Oct-10 9:22 
GeneralRe: Simple question from new sql server user ... Pin
Mycroft Holmes26-Oct-10 1:42
professionalMycroft Holmes26-Oct-10 1:42 
GeneralRe: Simple question from new sql server user ... Pin
NeverHeardOfMe26-Oct-10 2:00
NeverHeardOfMe26-Oct-10 2:00 
GeneralRe: Simple question from new sql server user ... Pin
Mycroft Holmes26-Oct-10 2:57
professionalMycroft Holmes26-Oct-10 2:57 
GeneralRe: Simple question from new sql server user ... Pin
PIEBALDconsult26-Oct-10 15:12
mvePIEBALDconsult26-Oct-10 15:12 
QuestionSQL Server 2008 R2: Errrors when sending ISO 8601 timestamp values as parameters to a parametrized insert statement Pin
Per Nilsson24-Oct-10 23:24
Per Nilsson24-Oct-10 23:24 
AnswerRe: SQL Server 2008 R2: Errrors when sending ISO 8601 timestamp values as parameters to a parametrized insert statement Pin
Bernhard Hiller24-Oct-10 23:32
Bernhard Hiller24-Oct-10 23:32 
QuestionDatabase Unit Testing with Visual Studio 2010 Pin
dotman124-Oct-10 16:38
dotman124-Oct-10 16:38 
QuestionModifiable field in sql server 2005 Pin
Zeyad Jalil24-Oct-10 1:55
professionalZeyad Jalil24-Oct-10 1:55 
AnswerRe: Modifiable field in sql server 2005 Pin
Mycroft Holmes24-Oct-10 11:57
professionalMycroft Holmes24-Oct-10 11:57 
GeneralRe: Modifiable field in sql server 2005 Pin
Zeyad Jalil24-Oct-10 21:24
professionalZeyad Jalil24-Oct-10 21:24 

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.