SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 Some SQL Server network properties
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

SwePeso
Patron Saint of Lost Yaks

Sweden
30213 Posts

Posted - 06/19/2008 :  09:58:45  Show Profile  Visit SwePeso's Homepage  Reply with Quote
DECLARE	@Stage TABLE
	(
		RowID INT IDENTITY(0, 1) PRIMARY KEY CLUSTERED,
		Data VARCHAR(90),
		Section INT
	)

INSERT	@Stage
	(
		Data
	)
EXEC	xp_cmdshell 'ipconfig /all'

DECLARE	@Section INT

SET	@Section = 0

UPDATE	@Stage
SET	@Section = Section =	CASE
					WHEN ASCII(LEFT(Data, 1)) > 32 THEN @Section + 1
					ELSE @Section
				END

SELECT		MAX(CASE WHEN x.minRowID IS NULL THEN NULL ELSE s.Data END) AS Header,
		MAX(CASE WHEN s.Data LIKE '%Host Name%' THEN RTRIM(SUBSTRING(s.Data, 45, 90)) END) AS HostName,
		MAX(CASE WHEN s.Data LIKE '%Media State%' THEN RTRIM(SUBSTRING(s.Data, 45, 90)) END) AS MediaState,
		MAX(CASE WHEN s.Data LIKE '%Description%' THEN RTRIM(SUBSTRING(s.Data, 45, 90)) END) AS [Description],
		MAX(CASE WHEN s.Data LIKE '%IP Address%' THEN RTRIM(SUBSTRING(s.Data, 45, 90)) END) AS IPaddress,
		MAX(CASE WHEN s.Data LIKE '%Physical Address%' THEN RTRIM(SUBSTRING(s.Data, 45, 90)) END) AS PhysicalAddress
FROM		@Stage AS s
LEFT JOIN	(
			SELECT		MIN(RowID) AS minRowID
			FROM		@Stage
			GROUP BY	Section
		) AS x ON x.minRowID = s.RowID
WHERE		s.Section > 0
GROUP BY	s.Section


E 12°55'05.25"
N 56°04'39.16"

Edited by - SwePeso on 06/19/2008 10:04:23

no_body_perfect
Starting Member

Egypt
1 Posts

Posted - 06/27/2008 :  18:22:44  Show Profile  Send no_body_perfect a Yahoo! Message  Reply with Quote
dear Peso
i interest in your post but really there are some parts i can't understand like
after declaring the @stage what u mean by

INSERT @Stage
(
Data
)

what is data you asked to insert

Thank you
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30213 Posts

Posted - 06/28/2008 :  03:41:48  Show Profile  Visit SwePeso's Homepage  Reply with Quote
"Data" is the name of the column where I insert the result of the DOS command "ipconfig /all".



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000