View Single Post

   
  #1 (permalink)  
Old 02-28-2008, 07:14 PM
Robert
 
Posts: n/a
Default Stored Procedure Syntax Help

I'm enhancing a large ASP application by replacing raw SQL statements
in the code with calls to stored procedures. I've seen this
recommended in many places to increase SQL Server effieicency.
Replacing select statements is going fine but I hit a sticking point
when trying to replace an update statement.

Currently, I use this kind of statement a lot in my ASP:

sql = "update"
sql = sql & " field1 = value1"
sql = sql & ",field2 = value2"
If Len(value3) Then sql = sql & ",field3 = value3"
sql = sql & " where ...., etc, etc

The important part here is checking if "value3" has a value before
inserting it into my SQL statement. So how can I put this update
statement into a stored procedure, pass in values for value1, value2,
and value3, and leave off the value3 part of the update if value3
comes in as null.

Thanks all.
Reply With Quote