Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2004
    Posts
    26

    Unanswered: Need Help Update And Insert

    I need a query to make an insert or and update in the same query

    thanks

  2. #2
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621
    A triggers?

  3. #3
    Join Date
    Feb 2004
    Posts
    26
    Originally posted by snail
    A triggers?
    no, juste a query !!!

  4. #4
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621
    Originally posted by superj
    no, juste a query !!!
    What do you mean 'in the same query'? And what is difference for you in case of batch?

  5. #5
    Join Date
    Feb 2004
    Posts
    26
    somthing like this

    UPDATE tempRetrait
    SET email = "#tmpemail#"
    WHERE IF email = "#tmpemail#"
    INSERT tbl(email,dateEntree)
    VALUES ("#tmpemail#","#now()#")


    Originally posted by snail
    What do you mean 'in the same query'? And what is difference for you in case of batch?

  6. #6
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621
    Originally posted by superj
    somthing like this

    UPDATE tempRetrait
    SET email = "#tmpemail#"
    WHERE IF email = "#tmpemail#"
    INSERT tbl(email,dateEntree)
    VALUES ("#tmpemail#","#now()#")
    Add begin tran, commit, some error handling with rollback... and it will be very the same query...

  7. #7
    Join Date
    Feb 2004
    Posts
    26
    i have this error !!!


    Error Diagnostic Information
    ODBC Error Code = 37000 (Syntax error or access violation)


    [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'IF'.


    SQL = "UPDATE tempRetrait SET email = "nicolas@publisoft.com" WHERE IF @@ROWCOUNT = 0 INSERT tbl(email,dateEntree) VALUES ("nicolas@publisoft.com","{ts '2004-02-19 17:07:35'}")"


    Originally posted by snail
    Add begin tran, commit, some error handling with rollback... and it will be very the same query...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •