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
 New to SQL Server Programming
 How to get values from Col with trailing spaces
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Analyzer
Posting Yak Master

United Kingdom
102 Posts

Posted - 07/23/2013 :  05:28:28  Show Profile  Reply with Quote
Hi. Performing security audit using command to retrieve data from Active Director about security groups and drop results into local tbl for analysis.

EXEC xp_cmdshell 'net group "AnalyticsDev" /domain'

Problem is the col created to store result is varchar(1000) and can hold 1-3 values (loginIDs) per row with lots of trailing/white space.

E.g. (EmpID101, EmpID250 EmpID10)

Is there a technique to extract the needed value (loginIDs) from col?

Thanks in advance

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 07/23/2013 :  05:30:25  Show Profile  Reply with Quote
yep there's

see

http://visakhm.blogspot.com/2010/02/parsing-delimited-string.html

http://visakhm.blogspot.com/2013/01/delimited-string-split-xml-parsing.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3744 Posts

Posted - 07/23/2013 :  06:30:19  Show Profile  Reply with Quote
quote:
Originally posted by visakh16

yep there's

see

http://visakhm.blogspot.com/2010/02/parsing-delimited-string.html

http://visakhm.blogspot.com/2013/01/delimited-string-split-xml-parsing.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs


Using while loops for splitting strings are usually inefficient if you have even moderately large amounts of data. Constructing an intermediate XML for this purpose is just awful from a performance perspective.

I would recommend Jeff Moden's delimitedSplit8K which can be found here in Fig. 21: http://www.sqlservercentral.com/articles/Tally+Table/72993/
Go to Top of Page

Analyzer
Posting Yak Master

United Kingdom
102 Posts

Posted - 07/23/2013 :  06:40:21  Show Profile  Reply with Quote
Hi. First thank I managed to parse the strings.

Another less techy method would be import .rpt into Excel, separate values into columns, re-import back into SQL Table

Appreciate your help

Martin
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 07/23/2013 :  07:35:48  Show Profile  Reply with Quote
quote:
Originally posted by Analyzer

Hi. First thank I managed to parse the strings.

Another less techy method would be import .rpt into Excel, separate values into columns, re-import back into SQL Table

Appreciate your help

Martin


Yep...thats also an option but would involve some manual effort in separating values
The given suggestions are all programmatically doing the same thing

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
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.06 seconds. Powered By: Snitz Forums 2000