Replace a special charecter in results

  • All,

    First time post and I am learning TSQL. Anyway, I have a weird issue that I was hoping you guys could help me with. I have an database that is housing a path used to locate an external file. This application was written many years ago and I am now trying to bring the files into the database as a VARBINARY. So, I a writing a script to do this and have a small problem.

    The table is holding the path like this "/folder/folder/file"

    I am trying to convert that path to "\folder\folder\file"

    In my Select statement I have

    SELECT ProdID, REPLACE (PATH, /, \) FROM dbo.blahblah

    The problem is that I can't figure out to make SQL understand that "/" is the character I want to replace. Am I going the right direction, or down a rabbit hole? Any help is appreciated.

  • You're on the right direction. You just need to quote your characters/strings. 😉

    SELECT ProdID, REPLACE (PATH, '/', '\')

    FROM (SELECT 1 AS ProdID, '/folder/folder/file' AS [PATH])blahblah

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • LOL, I quoted one but not the other, I never thought to try both. That worked, thanks! 🙂

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply