Remove specific character from string I have a variable which is a VARCHAR and will contain a list of folders (1 or more).
It may looks like that :

@Folder = '/folder1/folder2/'
or
@Folder = 'folder1/folder2/'
or
@Folder = '/Folder1/Folder2'


And if the first and the last characater of my string are '/', i want to remove them and my variable should be always 

@Folder = 'Folder1/Folder2'


Thanks for your help
You could use the LEFT() and RIGHT() functions to do this. 

DECLARE @Folder varchar(20) = '/folder1/folder2/';

IF LEFT(@folder,1) = '/' 
SET @Folder = RIGHT(@Folder ,LEN(@Folder)-1);

IF RIGHT(@folder,1) = '/' 
SET @Folder = LEFT(@Folder ,LEN(@Folder)-1);

SELECT @Folder;


Result

(No column name)
folder1/folder2