How to write a IF Condition in Stored Procedure
-
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
-
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
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.
-
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
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.