Click here to Skip to main content
15,924,402 members
Home / Discussions / Database
   

Database

 
GeneralIdentity Pin
Sebastian T Xavier5-Mar-08 18:59
Sebastian T Xavier5-Mar-08 18:59 
GeneralRe: Identity Pin
Vimalsoft(Pty) Ltd5-Mar-08 19:17
professionalVimalsoft(Pty) Ltd5-Mar-08 19:17 
GeneralRe: Identity Pin
Sebastian T Xavier5-Mar-08 19:34
Sebastian T Xavier5-Mar-08 19:34 
GeneralRe: Identity Pin
Vimalsoft(Pty) Ltd5-Mar-08 19:37
professionalVimalsoft(Pty) Ltd5-Mar-08 19:37 
GeneralRe: Identity Pin
Sebastian T Xavier5-Mar-08 19:40
Sebastian T Xavier5-Mar-08 19:40 
GeneralRe: Identity Pin
Khawar Abbas15-Mar-08 19:58
Khawar Abbas15-Mar-08 19:58 
GeneralRe: Identity Pin
Sebastian T Xavier5-Mar-08 21:25
Sebastian T Xavier5-Mar-08 21:25 
GeneralConditions Pin
AlexeiXX35-Mar-08 18:55
AlexeiXX35-Mar-08 18:55 
Hi all, thanks for looking

I need a storedprocedure that retrieves rows based on parameters
Example 1:
SELECT * FROM Users WHERE Name LIKE '%' + @str + '%'
This will return all rows that have the word @str in Name column
If i pass '' or '%' it will return all the rows

I need the same but for an int column
Example:
SELECT * FROM Users WHERE UserID = @UserID
If i pass a number, it will return a row of the user with UserID = @UserID
But if no parameter is passed it wont work
My question is
Is there any way i can make this last query to return all the rows if no @UsersID is passed

Ill be calling this SPs from ASP.NET

Im giving this examples, i know they might seem very easy, and you may say, make 2 SPs
But in fact, Ill have more than 5 diferent filters, all applied to the same table, and any combination of this parameters is valid (param 1 and param2, param 1 only, param 5 only, param 1 2 and 4, and so on), so if i implement this in separated SPs ill end up having more than 20 almost equal SPs

Any advice will be appeciated
Thanks in advance

Alexei Rodriguez

GeneralRe: Conditions Pin
pmarfleet5-Mar-08 19:38
pmarfleet5-Mar-08 19:38 
GeneralRe: Conditions Pin
AlexeiXX36-Mar-08 8:16
AlexeiXX36-Mar-08 8:16 
GeneralRe: Conditions Pin
Khawar Abbas16-Mar-08 1:43
Khawar Abbas16-Mar-08 1:43 
GeneralRe: Conditions Pin
AlexeiXX36-Mar-08 6:05
AlexeiXX36-Mar-08 6:05 
QuestionQuery Scenario Pin
RadioButton5-Mar-08 9:31
RadioButton5-Mar-08 9:31 
GeneralRe: Query Scenario Pin
Michael Potter5-Mar-08 10:03
Michael Potter5-Mar-08 10:03 
GeneralRe: Query Scenario Pin
Ashfield5-Mar-08 21:31
Ashfield5-Mar-08 21:31 
GeneralCreating a Help Form... [modified] Pin
new_phoenix5-Mar-08 9:17
new_phoenix5-Mar-08 9:17 
GeneralWrong forum Pin
pmarfleet5-Mar-08 10:11
pmarfleet5-Mar-08 10:11 
QuestionUsing ADO.Net to retrieve data from Excel 2007 - Cannot import more than 255 columns Pin
Mehawitchi5-Mar-08 4:33
Mehawitchi5-Mar-08 4:33 
GeneralRe: Using ADO.Net to retrieve data from Excel 2007 - Cannot import more than 255 columns Pin
pmarfleet5-Mar-08 8:37
pmarfleet5-Mar-08 8:37 
GeneralRe: Using ADO.Net to retrieve data from Excel 2007 - Cannot import more than 255 columns Pin
Mehawitchi5-Mar-08 10:11
Mehawitchi5-Mar-08 10:11 
GeneralRe: Using ADO.Net to retrieve data from Excel 2007 - Cannot import more than 255 columns Pin
pmarfleet5-Mar-08 21:38
pmarfleet5-Mar-08 21:38 
GeneralRe: Using ADO.Net to retrieve data from Excel 2007 - Cannot import more than 255 columns Pin
Mehawitchi7-Mar-08 9:49
Mehawitchi7-Mar-08 9:49 
GeneralRe: Using ADO.Net to retrieve data from Excel 2007 - Cannot import more than 255 columns Pin
jvandertol122-Jun-09 9:49
jvandertol122-Jun-09 9:49 
QuestionHow to Execute a DTS Package within a Procedure Pin
Vimalsoft(Pty) Ltd4-Mar-08 23:06
professionalVimalsoft(Pty) Ltd4-Mar-08 23:06 
AnswerRe: How to Execute a DTS Package within a Procedure Pin
pmarfleet5-Mar-08 1:14
pmarfleet5-Mar-08 1:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.