943,633 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 640
  • ASP.NET RSS
Feb 13th, 2008
0

stored procedure problem

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
u4umang2001 is offline Offline
28 posts
since Nov 2007
Feb 13th, 2008
0

Re: stored procedure problem

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
FeJoMaFe is offline Offline
1 posts
since Feb 2008
Feb 14th, 2008
0

Re: stored procedure problem

hi u4umang2001,
Quote ...
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.
ASP.NET Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 4
Light Poster
dilipv is offline Offline
30 posts
since Feb 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: datatype TEXT in stored procedure
Next Thread in ASP.NET Forum Timeline: Temporary Web Page problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC