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.
| Author |
Topic |
|
savvy95
Starting Member
23 Posts |
Posted - 2005-04-05 : 13:02:45
|
| The situation:I have a text field (MemberOf) which lists all the groups a user belongs to; separated by semicolons.What syntax do I use to separate the groups into separate fields?Example:CN=ORAdmin,OU=Email Distribution List,OU=DomainResources,DC=DOMAIN,DC=NET;CN=AdminAccess,OU=WebAccess,OU=Resources,OU=DomainResources,DC=DOMAIN,DC=NET;CN=CtgryMasterAccess,OU=WebAccess,OU=Resources,OU=DomainResources,DC=DOMA Notice the line has been truncated. The actual data from a flat file reads:"CN=ORAdmin,OU=Email Distribution List,OU=DomainResources,DC=DOMAIN,DC=NET;CN=AdminAccess,OU=WebAccess,OU=Resources,OU=DomainResources,DC=DOMAIN,DC=NET;CN=CtgryMasterAccess,OU=WebAccess,OU=Resources,OU=DomainResources,DC=DOMAIN,DC=NET;CN=Marketing,OU=Marketing,OU=TD,DC=DOMAIN,DC=NET"How can I retrieve the first group after each ";" (semicolon) and put the groups into a new table (UserGroups) so the result is:Group1 = ORAdminGroup2 = AdminAccessGroup3 = CtgryMasterAccessGroup4 = MarketingThanks for your help |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-04-05 : 13:22:42
|
| If the data is in a flat file then you can use bulk insert with a row terminator of ;.If you have it in a varchar then use http://www.nigelrivett.net/SQLTsql/ParseCSVString.html==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
savvy95
Starting Member
23 Posts |
Posted - 2005-04-05 : 13:49:55
|
| The function can be very useful; but unfortunately, not what I'm looking for. It doesn't work when I put the column name, memberOf.The flat file has more data than just memberOf. I import the file into a TEMP table and then I partition the data into other tables. The memberOf data needs to be broken out to list users and the groups they belong to.Thanks again |
 |
|
|
|
|
|
|
|