Search This Blog

Thursday, July 29, 2010

Sql query to get substring of column value

suppose i have column value i.e ../Images/photo.jpeg
But i want that my store procedure will return only Images/photo.jpeg
For this i can write a query in store procedure

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go




ALTER PROCEDURE [dbo].[csp_GetUserGallery]

AS
BEGIN
   

    Select   top 6 REPLACE (PhotoLink, '../' , ' ' ) as PhotoLink from HomePhotoGallery where Activegallery=1 order by PhotoID
END

Here photolink is column name in table and HomePhotoGallery is table name
Here i use top6 keyword that will return only 6 top six records of table arranged by Photoid

No comments:

Post a Comment