Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hi,i have a field VPATH which holds virtual path of files from a .net project. i have created a search for a Library section.i need to search only those pages which are inside "library" folder.folder name: libraryi tried to create a query using VPATH LIKE '%/library/%'. but it is showing result from all the folders. can anyone help me asap?mail to :priya.interactive@yahoo.co.in.
snSQL
Master Smack Fu Yak Hacker
1837 Posts
Posted - 2007-03-29 : 12:31:48
Some sample data and your whole query?
umapriya
Starting Member
5 Posts
Posted - 2007-03-29 : 13:40:47
data:VPATH Content/freegifts/f.aspx fff /popup/b.ascx bbb/library/l.ascx lll/library/a.aspx aaa /library/d.aspx dddthe datatable contains VPATH as one of the fields in it.i have two types of search in my site. one searches the entire site and other searches only library.In the above table i need to filter the pages those are inside "library" folder only. Query which i tried,select Content from <tablename> where VPATH Like '%/library/%' output i expected is:Content-------lllaaaddd but i got all the records from the table..hope this example will be help ful for u understand what i need ?
khtan
In (Som, Ni, Yak)
17689 Posts
Posted - 2007-03-29 : 13:45:42
What is the result that you got ?
declare @data table( VPATH varchar(20), Content varchar(30))insert into @dataselect '/freegifts/f.aspx', 'fff' union allselect '/popup/b.ascx', 'bbb' union allselect '/library/l.ascx', 'lll' union allselect '/library/a.aspx', 'aaa' union allselect '/library/d.aspx', 'ddd'select Contentfrom @datawhere VPATH like '%/library/%'/*Content ------------------------------ lllaaaddd*/
KH
umapriya
Starting Member
5 Posts
Posted - 2007-03-29 : 14:26:50
I am sorry..actually my colleague is trying this..he could be able the get the above output in SQL Query Builder. He is using a OLEDB namespace and objects on a ASP.NET web page. In this page he tried to build the query and execute the query which is not executing properly.Can anyone help me?Foldername: librarysample Table structure: VPATH------/library/a.aspx/library/b.aspx/freegifts/c.aspx/popup/d.aspxQuery: should return only those page's contents saved inside "library" folder.
[code]-- Prepare sample dataDECLARE @Sample TABLE (vPath VARCHAR(30))INSERT @SampleSELECT '/freegifts/f.aspx' UNION ALLSELECT '/popup/b.ascx' UNION ALLSELECT '/library/l.ascx' UNION ALLSELECT '/library/a.aspx' UNION ALLSELECT '/library/d.aspx'-- Show the expected outputSELECT RIGHT(vpath, CHARINDEX('/', REVERSE(vPath)) - 1)FROM @SampleWHERE vPath LIKE '%/library/%'[/code]Peter LarssonHelsingborg, Sweden