I'm trying to select a column with multiple functions and I dont know how. Lets say that my column's data returns data with values such as 'Foo_RockStar.Complete' and what I want to extract is the 'RockStar'. There could be lots of pre-fixes such as the 'Foo_' and lots of endings such as the '.Complete', so my initial query looked somthing like.... SELECT SUBSTRING([column1],4,20) REPLACE([column1],'.Complete','') AS [DesiredText] FROM MYTable WHERE [column1] like '%.Complete' The Desired outcome would be somthing like 'RockStar'
To answer your question about syntax of your SELECT statement, it would be something more like SELECT replace(SUBSTRING(@row,4,20),'.Complete','') AS [DesiredText] ... Are you looking for a solution that would account for the multiple prefixes and endings or does the query above meet your needs? This should work for what you need just replace @row with your column name in the select statement, to test the statement I had to create a variable to pass to it.: DECLARE @row varchar(50) SET @row = 'Foo_RockStar.Complete' SELECT SUBSTRING(@row,((CHARINDEX('_',@row)+1)),(CHARINDEX('.',@row)-(CHARINDEX('_',@row)+1)))