stored procedure problem

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2007
Posts: 28
Reputation: u4umang2001 is an unknown quantity at this point 
Solved Threads: 0
u4umang2001's Avatar
u4umang2001 u4umang2001 is offline Offline
Light Poster

stored procedure problem

 
0
  #1
Feb 13th, 2008
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
Thanks & Regards
Umang
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 1
Reputation: FeJoMaFe is an unknown quantity at this point 
Solved Threads: 0
FeJoMaFe FeJoMaFe is offline Offline
Newbie Poster

Re: stored procedure problem

 
0
  #2
Feb 13th, 2008
Hi u4umang2001,

Right now I don't have near to me sample code, but could you take a look at Dynamic SQL?

See the following URL: http://msdn2.microsoft.com/en-us/library/aa258848.aspx

Hope this helps,

FeJoMeFa
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 30
Reputation: dilipv is an unknown quantity at this point 
Solved Threads: 4
dilipv dilipv is offline Offline
Light Poster

Re: stored procedure problem

 
0
  #3
Feb 14th, 2008
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.
  1. CREATE PROCEDURE sp_myStoredProcedure
  2. @para1 varchar(100),
  3. @para2 varchar(100),
  4. @para3 varchar(100)
  5. AS
  6. if @para1 IS NULL
  7. update table1 set para2=@para2 and para3=@para3
  8. else
  9. update table1 set para1=@para1 And para2=@para2 And para3=@para3
  10. 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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 509 | Replies: 2
Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC