October 27, 2010 at 1:51 pm
I'm a bit of a novice with SQL and would greatly appreciate any assistance with my problem. I created a simple one column table containing all the sql servers in our company. Here is the code:
CREATE TABLE #tt_servers(svrname VARCHAR(255))
INSERT #tt_servers (svrname)
EXEC master..xp_CMDShell 'sqlcmd -Lc'
The problem is that some of the server names have the instance attached.
eg: SVRXYZ\DBN01 and others don't eg: SVRABCD
I need to cut off everything from the back slash to the right so that
SVRXYZ\DBN01 looks like this SVRXYZ.
Any suggestions will be greatly appreciated.
October 27, 2010 at 1:56 pm
checkout the left function, combined with charindex.
books online has nice info.
Off course your update statement should contain a where clause :
where servername like '%\%'
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
October 27, 2010 at 2:52 pm
Thank you very much. That's exactly what I needed!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply