PARSENAME

  • Good question. We have used the function in proc but I always face issue about what would be the order - left to right or right to left.. 🙁

    Thanks

  • Michael Riemer (10/25/2012)


    Another great question to learn from - thanks. I had heard of the function, but never knew what it did.

    I hadn't heard of it (so naturally didn't know what it did). Now I've heard of it and know what it does but I'm struggling to think of a situation where I'd need to use it. If it was a general parser that took a string as a parameter and parsed it by a character that was also a parameter, e.g.

    SELECT PARSESTRING('Mary had a little lamb', 4, ' ')

    returns 'little' as the fourth value from the start delimited by ' ' with PARSESTRING being the name of this

    (as far as I know) fictitious function,

    I could see a use for that. Now is somebody going to tell me function a exists with this capability? If so, I suggest PARSENAME is redundant as its functionality is already present. If not, why make something as restricted as PARSENAME?

    Edited for grammar

  • marlon.seton (11/19/2012)


    Now is somebody going to tell me function a exists with this capability? If so, I suggest PARSENAME is redundant as its functionality is already present. If not, why make something as restricted as PARSENAME?

    There is no such function. The limited functionality of PARSENAME is because it is actually intended for a very specific use: to parse tablenames. Since they can use one, two, three or four parts (**), divided by dots, that's what PARSENAME supports.

    (**) In case you're not aware: just the tablename, prefixed by schema (schema.table), in another database on the same instance (database.schema.table), or on another instance using a linked server (server.database.schema.table).


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

Viewing 3 posts - 31 through 32 (of 32 total)

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