Trim string after a certain character sql -
i have list of places many of places not have id appended @ end of name of places starts after dash character (-). need show name of place , not id. ids have length of 5 characters,
i.e :
132 rockaway blvd -12345 , 176-58 bayshore avenue -78952, 12-89 rosedale place need display: 132 rockaway blvd 176-58 bayshore avenue 12-89 rosedale place have tried `select distinct right(rtrim(placename),7) places` gives me last characters -12345
declare @table1 table(column1 varchar(200)) insert @table1(column1) values('132 rockaway blvd -12345') insert @table1(column1) values('176-58 bayshore avenue -78952') insert @table1(column1) values('12-89 rosedale place -9999999999') select column1, left(column1,len(column1)-charindex('-',reverse(column1))) @table1
--if can give me more example can modify query
Comments
Post a Comment