Click here to Skip to main content
15,914,162 members
Home / Discussions / Database
   

Database

 
QuestionPuzzled by converting date on an export [modified] Pin
Jack Fleet6-Aug-07 8:37
Jack Fleet6-Aug-07 8:37 
AnswerRe: Puzzled by converting date on an export Pin
Mike Dimmick6-Aug-07 12:38
Mike Dimmick6-Aug-07 12:38 
GeneralRe: Puzzled by converting date on an export Pin
Jack Fleet6-Aug-07 12:43
Jack Fleet6-Aug-07 12:43 
QuestionSQL Query Pin
sangramkp6-Aug-07 7:06
sangramkp6-Aug-07 7:06 
AnswerRe: SQL Query Pin
andyharman6-Aug-07 7:15
professionalandyharman6-Aug-07 7:15 
GeneralRe: SQL Query Pin
sangramkp6-Aug-07 7:40
sangramkp6-Aug-07 7:40 
GeneralRe: SQL Query Pin
andyharman6-Aug-07 8:17
professionalandyharman6-Aug-07 8:17 
AnswerRe: SQL Query Pin
Pete O'Hanlon6-Aug-07 22:05
mvePete O'Hanlon6-Aug-07 22:05 
In Sql Server from version 2000 onwards there is a feature called an INSTEAD OF trigger that you can use. To use it, you create a copy of your table as a view and use this as the target of your inserts. Behind this view, create a trigger with the signature INSTEAD OF INSERT where you would normally put the FOR INSERT.

The trigger would look something like this:
CREATE TRIGGER InsertIntoSummarySells
INSTEAD OF INSERT
AS
BEGIN
  DECLARE @C1 INT -- or whatever type it is
  DECLARE @C2 INT -- ...
  ... -- And so on, with the parameters

  SET NOCOUNT ON
  UPDATE tblSummarySells
  SET C5 = @C5,
  C6 = @C6,
  C7 = @C7
  WHERE
    C1 = @C1 AND C2 = @C2 AND C3 = @C3 AND C4 = @C4

  IF @@ROWCOUNT  = 0
  BEGIN
    INSERT INTO tblSummarySells ....
  END
END
Now, the advantage of this approach is that anytime you do an insert onto the view, this code will run so it should always behave consistently - rather than having to remember to call the stored procedure to perform the update.

Deja View - the feeling that you've seen this post before.

QuestionTimeout while reading data from database Pin
Muhammad Ahmed6-Aug-07 6:45
Muhammad Ahmed6-Aug-07 6:45 
AnswerRe: Timeout while reading data from database Pin
vimal_yet6-Aug-07 22:23
vimal_yet6-Aug-07 22:23 
AnswerRe: Timeout while reading data from database Pin
Pete O'Hanlon6-Aug-07 22:38
mvePete O'Hanlon6-Aug-07 22:38 
QuestionDataAdapter.Update Problem Pin
MohammadAmiry6-Aug-07 6:12
MohammadAmiry6-Aug-07 6:12 
Questionproblem with pop3 mail box Pin
shaikshavali6-Aug-07 2:17
shaikshavali6-Aug-07 2:17 
AnswerRe: problem with pop3 mail box Pin
Marek Grzenkowicz6-Aug-07 22:30
Marek Grzenkowicz6-Aug-07 22:30 
QuestionDate Range Pin
Brendan Vogt5-Aug-07 20:50
Brendan Vogt5-Aug-07 20:50 
AnswerRe: Date Range Pin
Krish - KP5-Aug-07 21:10
Krish - KP5-Aug-07 21:10 
QuestionReducing the Execution time of the Sql Server 2000 Stored procedure. Pin
tonic_valan5-Aug-07 20:32
tonic_valan5-Aug-07 20:32 
AnswerRe: Reducing the Execution time of the Sql Server 2000 Stored procedure. Pin
Marek Grzenkowicz5-Aug-07 21:02
Marek Grzenkowicz5-Aug-07 21:02 
GeneralRe: Reducing the Execution time of the Sql Server 2000 Stored procedure. Pin
tonic_valan5-Aug-07 22:03
tonic_valan5-Aug-07 22:03 
GeneralRe: Reducing the Execution time of the Sql Server 2000 Stored procedure. Pin
Marek Grzenkowicz5-Aug-07 23:47
Marek Grzenkowicz5-Aug-07 23:47 
GeneralRe: Reducing the Execution time of the Sql Server 2000 Stored procedure. Pin
tonic_valan6-Aug-07 1:50
tonic_valan6-Aug-07 1:50 
GeneralRe: Reducing the Execution time of the Sql Server 2000 Stored procedure. Pin
Marek Grzenkowicz6-Aug-07 21:57
Marek Grzenkowicz6-Aug-07 21:57 
GeneralRe: Reducing the Execution time of the Sql Server 2000 Stored procedure. Pin
tonic_valan7-Aug-07 20:33
tonic_valan7-Aug-07 20:33 
GeneralRe: Reducing the Execution time of the Sql Server 2000 Stored procedure. Pin
Marek Grzenkowicz7-Aug-07 23:12
Marek Grzenkowicz7-Aug-07 23:12 
GeneralRe: Reducing the Execution time of the Sql Server 2000 Stored procedure. Pin
tonic_valan8-Aug-07 23:34
tonic_valan8-Aug-07 23:34 

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.