-
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.
-
Try this:
SELECT SELECT LEFT(srvname, CHARINDEX('\', srvname) -1) FROM sysservers
WHERE srvid = '0'