Results 1 to 2 of 2

Thread: Sql Programming

  1. #1
    Join Date
    Dec 2002
    Location
    Los Angeles
    Posts
    11

    Sql Programming

    What I want to do is remove part of a result from a query. I am selecting the srvname from sysservers as follows.

    SELECT srvname from sysservers
    Where srvid ='0'

    When the name is returned some times it might be like servername\instance. What I need to do is cut off the \ and everything after that so that my result is just servername. I am then using this result in a cursor to go after server shares. The length of the servername varies. Any suggestions.

  2. #2
    Join Date
    Dec 2004
    Posts
    502
    Try this:

    SELECT SELECT LEFT(srvname, CHARINDEX('\', srvname) -1) FROM sysservers
    WHERE srvid = '0'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •