lmf232s
07-11-2006, 12:00 PM
I would like to remove my dynamic sql statements from code and place them in a stored procedure.
I found this article which talks about it and shows a very simple example of passing in 1 parameter.
http://www.4guysfromrolla.com/webtech/102300-1.shtml
Unfortunetaly im in a possession where i will need to pass in multiple parameters where there's a chance that only 1 may have a value.
I thought about maybe just adding all the fields and doing a Like on all of them (this query in question will be a like search as im searching form First name, Last name, company name, etc) but this just does not seem like a very good structure.
So i thought i would see what you guys think.
The basic structure of the query i need to try to implement is along the lines of this and then convert this to a stored procedure. If nothing else i can just build the sql statement in the business layer but i thought i would try to put it in a SP.
sSQL = "SELECT * FROM TABLE WHERE "
If FistName <> "" Then
sSQL = sSQL & " FirstName Like '" & FirstName & "%'"
End If
ETC.........
I found this article which talks about it and shows a very simple example of passing in 1 parameter.
http://www.4guysfromrolla.com/webtech/102300-1.shtml
Unfortunetaly im in a possession where i will need to pass in multiple parameters where there's a chance that only 1 may have a value.
I thought about maybe just adding all the fields and doing a Like on all of them (this query in question will be a like search as im searching form First name, Last name, company name, etc) but this just does not seem like a very good structure.
So i thought i would see what you guys think.
The basic structure of the query i need to try to implement is along the lines of this and then convert this to a stored procedure. If nothing else i can just build the sql statement in the business layer but i thought i would try to put it in a SP.
sSQL = "SELECT * FROM TABLE WHERE "
If FistName <> "" Then
sSQL = sSQL & " FirstName Like '" & FirstName & "%'"
End If
ETC.........