TruncateCommaDeliminatedIPData

-- The IP data in v_gs_network_adapter_configur is comma delimited.  Truncate to just get the four octet version

CREATE FUNCTION [dbo].[TruncateCommaDeliminatedIPData] (@IPData varchar (64))
RETURNS varchar (64)
AS 
BEGIN
DECLARE @ReturnIP varchar (64)
IF (@IPData not like '[1,2]%')
SET @ReturnIP = '0.0.0.0';
ELSE
SET @ReturnIP = left (@IPData, case when charindex (',', @IPData, 1) > 0 then charindex (',', @IPData, 1) - 1 else len (@IPData) end);
RETURN @ReturnIP
END
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s