Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Substring/Charindex Help - Resolved

Author  Topic 

Brittney10
Posting Yak Master

154 Posts

Posted - 2011-08-18 : 10:32:02
I'm trying to pull a computer name out of a domain name. For example: ComputerName.Domain.com. All I really need is the ComputerName, so i need to remove everything to the right of the first period. Any ideas how to do this?

Kristen
Test

22859 Posts

Posted - 2011-08-18 : 10:42:45
[code]
DECLARE @strDomain varchar(1000)
SELECT @strDomain = 'ComputerName.Domain.com'
SELECT LEFT(@strDomain, CHARINDEX('.', @strDomain)-1)
[/code]
Go to Top of Page

Brittney10
Posting Yak Master

154 Posts

Posted - 2011-08-18 : 10:44:09
That works! THANKS!
Go to Top of Page
   

- Advertisement -