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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Like operator

Author  Topic 

krpmahesh
Starting Member

2 Posts

Posted - 2008-02-14 : 01:50:05
I have a column named tags which contains tagnames seperated by commas now i have to compare this column with a parameter named tagname which contains a single tagname how to do this.Please help me

here is my procedure

ALTER PROCEDURE [dbo].[ProcSoftwaresGetSoftwaresbyTags]
(
@FileTag Varchar(64)
)
AS
BEGIN

SELECT Category.CategoryName, Softwares.SoftwareFileID, Softwares.CategoryID, Softwares.FileName, Softwares.FileImage,Softwares.FilePath, Softwares.FilePublisher,
Softwares.Adminrating, Softwares.FileDownloadCount,substring(Softwares.FileDescription,1,200)as FileDescription,convert(Varchar(12),Softwares.FilePostedDate,109)as FilePostedDate,Softwares.FileSize, SystemRequirements.OperatingSystem
FROM Category INNER JOIN
Softwares ON Category.CategoryID = Softwares.CategoryID INNER JOIN
SystemRequirements ON Softwares.SoftwareFileID = SystemRequirements.SoftwareRequirementID where substring(Softwares.FileTag,0,3) LIKE substring(@FileTag,0,3) and FileStatus=1
END

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-14 : 03:09:54
where substring(Softwares.FileTag,0,3) LIKE '%' + substring(@FileTag,0,3) + '%'
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-02-14 : 03:39:55

Also try

where Softwares.FileTag LIKE substring(@FileTag,0,3) + '%'

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

krpmahesh
Starting Member

2 Posts

Posted - 2008-02-14 : 06:05:00
Thank you very much
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-14 : 06:17:28
where Softwares.FileTag LIKE '%' + substring(@FileTag, 1, 3) + '%'


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-02-14 : 06:25:14
quote:
Originally posted by Peso

where Softwares.FileTag LIKE '%' + substring(@FileTag, 1, 3) + '%'


E 12°55'05.25"
N 56°04'39.16"



I forget about first value of substring

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -