0

Hi

i am passing three parameters to my stored procedure.

now in stored procedure i want to execute the query on the basis of given condition.

suppose i m passing para1, para2 and para3.

now i want update table1

if(para1='' or para1= null) then
'update table1 set para2='''+@para2+''' and para3='''+@para3+''''
else
'update table1 set para1='''+@para1+''' and para2='''+@para2+''' and para3='''+@para3+''' '

how can i do this???


please help...


Thanks in advance

3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by dilipv
0

hi u4umang2001,

if(para1='' or para1= null) then
'update table1 set para2='''+@para2+''' and para3='''+@para3+''''
else
'update table1 set para1='''+@para1+''' and para2='''+@para2+''' and para3='''+@para3+''' '

Your query is little bit simple but you should try first using various article. These articles can be easily found using Google. If you want to learn things, you should try atleast once.
Following is solution for your query.

CREATE PROCEDURE sp_myStoredProcedure
   @para1   varchar(100),
   @para2   varchar(100),
   @para3   varchar(100)
AS
   if @para1 IS NULL
        update table1 set para2=@para2 and para3=@para3
   else
        update table1 set para1=@para1 And para2=@para2 And para3=@para3
Go

Hope this will help you. Don't rely on others, first try yourself if not possible then ask for solution.
Thanks & Regards
Dilip Kumar Vishwakarma
Programmer
.Net Consulting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.