Thursday, April 1, 2010

Query to extract extension of files

Do you want to extact your file extension. Do it using SQL! As follow:-


SELECT Collection.Item_No,

'~/ThumbNail/' + substring(Imagefile,0,CHARINDEX('.',Imagefile,0))  + '_thumb' + substring(Imagefile,CHARINDEX('.',Imagefile,0),len(Imagefile))  ThumbNail,

'this.src=''' +  'Gallery/' + ImageFile + '''' MouseOver,

'this.src=''' +  'ThumbNail/' + substring(Imagefile,0,CHARINDEX('.',Imagefile,0))  + '_thumb' +

substring(Imagefile,CHARINDEX('.',Imagefile,0),len(Imagefile)) + '''' MouseOut,

Collection.Title, Artist.[Artist Name] AS Artist, Category.Name AS Category, Media.Media, Surface.Surface_name as Surface, styles.style_name as Style FROM Collection INNER JOIN Artist ON Collection.Artist = Artist.ID INNER JOIN Category ON Collection.cat_id = Category.ID INNER JOIN Media ON Collection.Media = Media.ID INNER JOIN Surface ON Collection.Surface = Surface.ID INNER JOIN styles ON = styles.ID



No comments: