Click here to Skip to main content
16,006,341 members
Home / Discussions / Database
   

Database

 
AnswerRe: Database Explorer Database Connection Pin
Rob Graham9-Jan-07 11:53
Rob Graham9-Jan-07 11:53 
QuestionTable-value function performance Pin
kmaclean9-Jan-07 9:51
kmaclean9-Jan-07 9:51 
QuestionOpposite of the SQL "IN" statement? Pin
dspyank9-Jan-07 6:17
dspyank9-Jan-07 6:17 
QuestionRe: Opposite of the SQL "IN" statement? Pin
Chris Meech9-Jan-07 6:24
Chris Meech9-Jan-07 6:24 
AnswerRe: Opposite of the SQL "IN" statement? Pin
kmaclean9-Jan-07 11:32
kmaclean9-Jan-07 11:32 
AnswerRe: Opposite of the SQL "IN" statement? Pin
Saud AKhter16-Jan-07 20:22
Saud AKhter16-Jan-07 20:22 
QuestionProcedure with multiple parameters and multiple Select Statements Pin
rodney.fetterolf9-Jan-07 3:48
rodney.fetterolf9-Jan-07 3:48 
AnswerRe: Procedure with multiple parameters and multiple Select Statements Pin
andyharman9-Jan-07 5:29
professionalandyharman9-Jan-07 5:29 
Try the following:
CREATE PROCEDURE usp_SearchItems
    @pName NVARCHAR(75),
    @pNSN NVARCHAR(16),
    @pTPart NVARCHAR(20),
    @pVPart NVARCHAR(50)
AS BEGIN
    DECLARE @pQuery NVARCHAR(1024)

    SET @pQuery = 'SELECT * FROM tblItems WHERE (fldInactive = 0)'
    IF (@pName<>'') BEGIN
        SET @pQuery = @pQuery + ' AND (fldItem LIKE ''%' + REPLACE(@pName, '''', '''''') + '%'')'
    END
    IF (@pNSN<>'') BEGIN
        SET @pQuery = @pQuery + ' AND (fldNSN LIKE ''%' + REPLACE(@pNSN, '''', '''''') + '%'')'
    END
    SET @pQuery = @pQuery + ' ORDER BY fldItem'

    --PRINT @pQuery
    EXEC(@pQuery)
END

If you have any problems then uncomment the "PRINT" statement to find out what the final contructed query was.

The "REPLACE" function is being used to protect the stored procedure against quote characters. Do a search for "SQL Injection Attacks" to find out more about this problem.

Regards
Andy
AnswerRe: Procedure with multiple parameters and multiple Select Statements Pin
M.H.1.2.314-Jan-07 21:46
M.H.1.2.314-Jan-07 21:46 
QuestionWhat is "N" in OBJECTPROPERTY(id, N'IsUserTable') = 1) Pin
Nick1977_209-Jan-07 3:06
Nick1977_209-Jan-07 3:06 
AnswerRe: What is "N" in OBJECTPROPERTY(id, N'IsUserTable') = 1) Pin
Pete O'Hanlon9-Jan-07 3:36
mvePete O'Hanlon9-Jan-07 3:36 
GeneralRe: What is "N" in OBJECTPROPERTY(id, N'IsUserTable') = 1) Pin
Rob Graham9-Jan-07 3:46
Rob Graham9-Jan-07 3:46 
GeneralRe: What is "N" in OBJECTPROPERTY(id, N'IsUserTable') = 1) Pin
Pete O'Hanlon9-Jan-07 4:11
mvePete O'Hanlon9-Jan-07 4:11 
GeneralRe: What is "N" in OBJECTPROPERTY(id, N'IsUserTable') = 1) Pin
Rob Graham9-Jan-07 6:45
Rob Graham9-Jan-07 6:45 
GeneralRe: What is "N" in OBJECTPROPERTY(id, N'IsUserTable') = 1) Pin
Nick1977_209-Jan-07 17:39
Nick1977_209-Jan-07 17:39 
Question.Net 2.0 Table Adapter best practice Pin
Adam Crawford9-Jan-07 0:58
Adam Crawford9-Jan-07 0:58 
AnswerRe: .Net 2.0 Table Adapter best practice Pin
Rob Graham9-Jan-07 3:52
Rob Graham9-Jan-07 3:52 
GeneralRe: .Net 2.0 Table Adapter best practice Pin
Adam Crawford9-Jan-07 4:22
Adam Crawford9-Jan-07 4:22 
GeneralRe: .Net 2.0 Table Adapter best practice Pin
Pete O'Hanlon9-Jan-07 4:36
mvePete O'Hanlon9-Jan-07 4:36 
GeneralRe: .Net 2.0 Table Adapter best practice Pin
Rob Graham9-Jan-07 6:58
Rob Graham9-Jan-07 6:58 
QuestionFine Tuning of Query Pin
Sasmi9-Jan-07 0:56
Sasmi9-Jan-07 0:56 
AnswerRe: Fine Tuning of Query Pin
Pete O'Hanlon9-Jan-07 1:30
mvePete O'Hanlon9-Jan-07 1:30 
Questionretrieving data from sql database Pin
rahulpasupuleti8-Jan-07 23:53
rahulpasupuleti8-Jan-07 23:53 
AnswerRe: retrieving data from sql database Pin
Colin Angus Mackay9-Jan-07 0:30
Colin Angus Mackay9-Jan-07 0:30 
QuestionIntegrating SQL server 2005 Reporting Services into asp.net Application Pin
Sarath Vellampalli Babu8-Jan-07 20:28
Sarath Vellampalli Babu8-Jan-07 20:28 

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.