Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2002
    Posts
    10

    Unanswered: Relace function of mysql

    Hi,

    Want to know that is their any option of inserting a record if the record does not exist in the table..while firing update query.

    In mysql, we have replace which updates or inserts the record.

    do let me know

    thanx,
    vivek.

  2. #2
    Join Date
    Dec 2001
    Location
    Toronto, Canada
    Posts
    335
    No SQL Server does not have a command like that. In my case all of my commands are done within a stored procedure, so I first check to see if the record exists, if yes then UPDATE else INSERT.

    Code:
    IF EXISTS (SELECT * FROM myTable WHERE pkey = @pkey) BEGIN
       UPDATE myTable
            .
            .
            .
            .
    END ELSE
        INSERT myTable
            .
            .
            .
            .
    END
    MCDBA

  3. #3
    Join Date
    Mar 2002
    Posts
    10

    Will be trying with SP

    Thanx,

    will surely try with Stored procs.

    regards,
    vivek.

Posting Permissions

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