User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 423,336 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 5,234 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums
Views: 1130 | Replies: 3
Reply
Join Date: Dec 2006
Posts: 2
Reputation: Mohfeza is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Mohfeza Mohfeza is offline Offline
Newbie Poster

Help MsSQL stored procedure

  #1  
Jun 21st, 2008
please help for MsSQL stored procedure for ASP.net/C#. Inside stored procedure i used 4 different statements in where clause . first one is working but last 3's are not . Statements are given below-


FILENAME LIKE ''%'+ @FILENAMETEXT +'%''
FILENAME LIKE '+ @FILENAMETEXT +'%''
SUBSTRING(FILENAME,1,4)='+@FILENAMETEXT+'
LEFT(FILENAME,4)='+@FILENAMETEXT+'


bunch of code for where clause are given below-

DECLARE @FILENAMETEXT CHAR(4)
DECLARE @CONDITION VARCHAR(2000)
SET @FILENAMETEXT='http'



SET @CONDITION = ' WHERE ('
SET @CONDITION = @CONDITION + 'TITLE LIKE ''%' +@SearchText+ '%'' OR DESCRIPTION LIKE ''%'+@SearchText+ '%'' OR TAGS LIKE ''%'+@SearchText+ '%'')
AND FILENAME LIKE ''%'+ @FILENAMETEXT +'%'' AND ISAPPROVED=1 AND ENCODESTATUS=1 AND ISARCHIVED=0 AND ISDELETED=0 '

SET @CONDITION = ' WHERE ('
SET @CONDITION = @CONDITION + 'TITLE LIKE ''%' +@SearchText+ '%'' OR DESCRIPTION LIKE ''%'+@SearchText+ '%'' OR TAGS LIKE ''%'+@SearchText+ '%'')
AND FILENAME LIKE '+ @FILENAMETEXT +'%'' AND ISAPPROVED=1 AND ENCODESTATUS=1 AND ISARCHIVED=0 AND ISDELETED=0 '

SET @CONDITION = ' WHERE ('
SET @CONDITION = @CONDITION + 'TITLE LIKE ''%' +@SearchText+ '%'' OR DESCRIPTION LIKE ''%'+@SearchText+ '%'' OR TAGS LIKE ''%'+@SearchText+ '%'')
AND SUBSTRING(FILENAME,1,4)='+@FILENAMETEXT+' AND ISAPPROVED=1 AND ENCODESTATUS=1 AND ISARCHIVED=0 AND ISDELETED=0 '


SET @CONDITION = ' WHERE ('
SET @CONDITION = @CONDITION + 'TITLE LIKE ''%' +@SearchText+ '%'' OR DESCRIPTION LIKE ''%'+@SearchText+ '%'' OR TAGS LIKE ''%'+@SearchText+ '%'')
AND LEFT(FILENAME,4)='+@FILENAMETEXT+' AND ISAPPROVED=1 AND ENCODESTATUS=1 AND ISARCHIVED=0 AND ISDELETED=0 '






please reply me as soon as possible
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2008
Posts: 295
Reputation: tesuji is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 41
tesuji tesuji is offline Offline
Posting Whiz in Training

Re: Help MsSQL stored procedure

  #2  
Jun 22nd, 2008
Well, looking at your short code fragments it seems to be hard to me understanding your problem. I would suggest that you post the really complete (from create procedure... till go)

krs,
tesu
Reply With Quote  
Join Date: Apr 2008
Posts: 39
Reputation: omrsafetyo is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 8
omrsafetyo omrsafetyo is offline Offline
Light Poster

Re: Help MsSQL stored procedure

  #3  
Jun 29th, 2008
I would also wrap your sql in some code=sql tags. It's hard to see everything - but for instance, it looks like you have some mixed and/or missing quotes
Reply With Quote  
Join Date: Jun 2008
Posts: 57
Reputation: varmadba is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 7
varmadba varmadba is offline Offline
Junior Poster in Training

Re: Help MsSQL stored procedure

  #4  
Jun 30th, 2008
Hey,

i didn't get you but from what i understood

don't u think these 4 statements are not similar

 FILENAME LIKE ''%'+ @FILENAMETEXT +'%''
          FILENAME LIKE '+ @FILENAMETEXT +'%''
         SUBSTRING(FILENAME,1,4)='+@FILENAMETEXT+'
         LEFT(FILENAME,4)='+@FILENAMETEXT+' 

1st one:
 FILENAME LIKE ''%'+ @FILENAMETEXT +'%'' 
This will return searched words any where in the a row

2nd one :
 FILENAME LIKE '+ @FILENAMETEXT +'%'' 
This will return any rows starting with searched words

3rd one :
 SUBSTRING(FILENAME,1,4)='+@FILENAMETEXT+' 
This will return any rows if the searched string is in the first 4 char

4th one:
 LEFT(FILENAME,4)='+@FILENAMETEXT+'  
This will return any rows if the searched string is in the first 4 char

so you have o/p when using the first code
:- Varma

Please Join Mysql Community:
http://www.orkut.com/Community.aspx?cmm=52345386
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MS SQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 11:38 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC