SQL Server Right() function to remove characters from certain point on column

DECLARE @YourTable table (RowValue varchar(50))
INSERT @YourTable VALUES ('0002 55 Actor Hill - 0002')
INSERT @YourTable VALUES ('0004 57 Adair - 0004')
INSERT @YourTable VALUES ('0005 74 Adams - 0005')

SELECT 
    LEFT(RowValue,CHARINDEX(' - ',RowValue)-1), '|'+LEFT(RowValue,CHARINDEX(' - ',RowValue)-1)+'|'
    FROM @YourTable



http://stackoverflow.com/questions/4409351/sql-server-right-function-to-remove-characters-from-certain-point-on-column
Advertisements
By simplemsexchange Posted in SQL 2008

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s