Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to write a IF Condition in Stored Procedure

How to write a IF Condition in Stored Procedure

Scheduled Pinned Locked Moved ASP.NET
databasehelpregextutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Abhishek Boga
    wrote on last edited by
    #1

    Hi.. 1) I was trying to create a IF Condition in stored procedure where i need to compare if old value and new value is present/not present in the database. Dont know the Syntax to write the above said query in Stored procedure. 2) I have created a variabl name 'add', 'change', 'remove'. The old value and new value are two different columns in the table. What i want is : If old value is null and new value is present then 'add' get incremented by 1, if old value is present and it has been modified in new value and if the old value string does not match with the new value then 'change' get incremented by 1, if old value is present and it has bee deleted in new value then 'remove' get incremented by 1. Kindly help me out as early as possible as these is where i stuck for the last few days and i need to resolve this soon. Abhishek

    C P 2 Replies Last reply
    0
    • A Abhishek Boga

      Hi.. 1) I was trying to create a IF Condition in stored procedure where i need to compare if old value and new value is present/not present in the database. Dont know the Syntax to write the above said query in Stored procedure. 2) I have created a variabl name 'add', 'change', 'remove'. The old value and new value are two different columns in the table. What i want is : If old value is null and new value is present then 'add' get incremented by 1, if old value is present and it has been modified in new value and if the old value string does not match with the new value then 'change' get incremented by 1, if old value is present and it has bee deleted in new value then 'remove' get incremented by 1. Kindly help me out as early as possible as these is where i stuck for the last few days and i need to resolve this soon. Abhishek

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      1 - is a SQL question. The books online that come with SQL Server will answer it, too 2 - this is still question 1 ?

      Abhishek Boga wrote:

      Kindly help me out as early as possible as these is where i stuck for the last few days and i need to resolve this soon.

      You've spent a couple of days, what have you tried ? What research did you do ? Where are you at ? Why not tell us instead of asking us to start from scratch ?

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      1 Reply Last reply
      0
      • A Abhishek Boga

        Hi.. 1) I was trying to create a IF Condition in stored procedure where i need to compare if old value and new value is present/not present in the database. Dont know the Syntax to write the above said query in Stored procedure. 2) I have created a variabl name 'add', 'change', 'remove'. The old value and new value are two different columns in the table. What i want is : If old value is null and new value is present then 'add' get incremented by 1, if old value is present and it has been modified in new value and if the old value string does not match with the new value then 'change' get incremented by 1, if old value is present and it has bee deleted in new value then 'remove' get incremented by 1. Kindly help me out as early as possible as these is where i stuck for the last few days and i need to resolve this soon. Abhishek

        P Offline
        P Offline
        praveen c byzan com
        wrote on last edited by
        #3

        hi, if you are using any id field in the table then write a select query using that id and value and find if the column value is null, if null then insert record,if not null then find whether old value and new are equal if not then update,if new value is null then delete the record, thats it praveen.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups