Click here to Skip to main content
15,888,090 members
Home / Discussions / Database
   

Database

 
GeneralRe: Semicolon delimited lists in SQL Pin
.dan.g.21-Nov-13 14:13
professional.dan.g.21-Nov-13 14:13 
Questionfind total money of parent node of tree according to a particular pattern Pin
jitendra raj20-Nov-13 5:54
jitendra raj20-Nov-13 5:54 
AnswerRe: find total money of parent node of tree according to a particular pattern Pin
Mycroft Holmes20-Nov-13 19:25
professionalMycroft Holmes20-Nov-13 19:25 
GeneralRe: find total money of parent node of tree according to a particular pattern Pin
jitendra raj20-Nov-13 22:46
jitendra raj20-Nov-13 22:46 
GeneralRe: find total money of parent node of tree according to a particular pattern Pin
Mycroft Holmes21-Nov-13 1:35
professionalMycroft Holmes21-Nov-13 1:35 
AnswerRe: find total money of parent node of tree according to a particular pattern Pin
Jörgen Andersson21-Nov-13 1:37
professionalJörgen Andersson21-Nov-13 1:37 
GeneralRe: find total money of parent node of tree according to a particular pattern Pin
jschell21-Nov-13 8:30
jschell21-Nov-13 8:30 
QuestionDynamic Filter Stored Procedure Pin
Commish1319-Nov-13 6:38
professionalCommish1319-Nov-13 6:38 
I'm trying to write a complex stored procedure that will filter my GridView. Right now I'm using a If statement but I rather to a way with that and some how run the procedure depending on what I type into my text box. Instead of having:

@SearchBy = 'Username' OR
@SearchBy = 'State' OR
@SearchBy = 'AreaNumber'

Also

WHERE
Username LIKE '%' + @SearchVal + '%'
OR State LIKE '%' + @SearchVal + '%'
OR AreaNumber LIKE '%' + @SearchVal + '%'

Is there a way to do something like:
These don't work

@SearchBy = ''
@SearchBy = '' LIKE '%' + @SearchVal + %


This is my code and hopefully it will clear up what I'm trying to say above:

ALTER PROCEDURE [dbo].[SearchEmpRecords_Sp2]
@SearchBy varchar(50) = ISNull,
@SearchVal varchar(50) = ISNull


AS
BEGIN
DECLARE @sql NVARCHAR(1000)

IF
@SearchBy = 'Username'or
@SearchBy = 'State' or
@SearchBy = 'AreaNumber'
BEGIN
SELECT
EmployeeID,
Username,
State,
AreaNumber
FROM Employees
WHERE
Username LIKE '%' + @SearchVal + '%'
OR State LIKE '%' + @SearchVal + '%'
OR AreaNumber LIKE '%' + @SearchVal + '%'
END
ELSE
BEGIN
SELECT
EmployeeID,
Username,
State,
AreaNumber
FROM Employees
END
END
EXECUTE sp_executesql @sql


Also the Username, State, AreaNumber are in my aspx code. They are in a dropdown list and part of a SelectedItem routine. I don't know if you needed to know that but I put it in here just in case.
AnswerRe: Dynamic Filter Stored Procedure Pin
Mycroft Holmes19-Nov-13 12:02
professionalMycroft Holmes19-Nov-13 12:02 
Questionhow to write MAX query Pin
spanner2118-Nov-13 20:15
spanner2118-Nov-13 20:15 
AnswerRe: how to write MAX query Pin
Wayne Gaylard18-Nov-13 20:39
professionalWayne Gaylard18-Nov-13 20:39 
GeneralRe: how to write MAX query Pin
spanner2118-Nov-13 21:11
spanner2118-Nov-13 21:11 
GeneralRe: how to write MAX query Pin
Wayne Gaylard18-Nov-13 21:17
professionalWayne Gaylard18-Nov-13 21:17 
AnswerRe: how to write MAX query Pin
Mycroft Holmes18-Nov-13 21:11
professionalMycroft Holmes18-Nov-13 21:11 
AnswerRe: how to write MAX query Pin
Peter Leow18-Nov-13 23:39
professionalPeter Leow18-Nov-13 23:39 
Questionhow can optimize a query in sql server Pin
mhd.sbt17-Nov-13 4:15
mhd.sbt17-Nov-13 4:15 
AnswerRe: how can optimize a query in sql server Pin
Maciej Los17-Nov-13 5:44
mveMaciej Los17-Nov-13 5:44 
GeneralRe: how can optimize a query in sql server Pin
PIEBALDconsult18-Nov-13 15:42
mvePIEBALDconsult18-Nov-13 15:42 
AnswerRe: how can optimize a query in sql server Pin
Jörgen Andersson18-Nov-13 3:00
professionalJörgen Andersson18-Nov-13 3:00 
QuestionSRSS 2008 RepeatOnNewPage not really work on the “2nd last” page Pin
F.E.L.I.X.15-Nov-13 0:44
F.E.L.I.X.15-Nov-13 0:44 
GeneralMessage Closed Pin
14-Nov-13 15:34
professionalMember 1040275014-Nov-13 15:34 
GeneralRe: Hadoop + esProc Help You Replace IOE Pin
Eddy Vluggen14-Nov-13 22:29
professionalEddy Vluggen14-Nov-13 22:29 
Questionstoredprocedures Pin
Member 1039766114-Nov-13 4:07
Member 1039766114-Nov-13 4:07 
AnswerRe: storedprocedures Pin
Eddy Vluggen14-Nov-13 6:52
professionalEddy Vluggen14-Nov-13 6:52 
GeneralRe: storedprocedures Pin
Member 1039766114-Nov-13 7:31
Member 1039766114-Nov-13 7:31 

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.