473,396 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

splitting a comma seperated column into multiple rows

Hi i want to create a table as follows :

if exists (select * from dbo.sysobjects where id =
object_id(N'[Indexes]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [Indexes]
GO

Create table Indexes(indexname Varchar(100), index_Description
Varchar(100), index_keys Varchar(100))
GO

INSERT INTO Indexes EXEC sp_helpindex 'SDM_Fact_Order_Detail'
GO

This will give me a table (northwind)

IX_Auto_SDM_Fact_FK_Shipped_Date nonclustered located on
SAMIS_SDM_Index FK_Shipped_Date

IX_Auto_SDM_Fact_Order_Detail_FK_Insert_Date clustered located on
SAMIS_SDM_Data1 FK_Insert_Date, FK_Insert_Time

As you see sp_helpindex will give me a comma seperated field. I want
to split the third column FK_Insert_Date, FK_Insert_Time into a extra
row
Like this :

IX_Auto_SDM_Fact_FK_Shipped_Date FK_Shipped_Date
IX_Auto_SDM_Fact_Order_Detail_FK_Insert_Date FK_Insert_Date
IX_Auto_SDM_Fact_Order_Detail_FK_Insert_Date FK_Insert_Time

Can anyone help me with this?

Thanx

Hennie

Jan 18 '06 #1
1 2979
Hi, Hennie

If you need the columns that are part of an index for a specified
table, you can use something like this:

SELECT i.name as IndexName, c.name as ColumnName
FROM sysindexes i
INNER JOIN sysindexkeys k ON i.id=k.id AND i.indid=k.indid
INNER JOIN syscolumns c ON c.id=k.id and c.colid=k.colid
WHERE i.id=OBJECT_ID('Order Details')

If you really want to split some other comma-delimited value (that
cannot be obtained in any other way), see this article by Erland
Sommarskog, SQL Server MVP:
http://www.sommarskog.se/arrays-in-sql.html

Razvan

Jan 18 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Craig Keightley | last post by:
is it possible to compare acomma separated list aginst another eg comma list 1 => 1,2,3,4,5 comma list 2 => 3,5 can you check that 3 is in both, and 5 is in both, therfore they match??? the...
2
by: N | last post by:
Hi, I would like to parse out each value that is seperated by a comma in a field and use that value to join to another table. What would be the easiest way to do so without having to write a...
9
by: Dr. StrangeLove | last post by:
Greetings, Let say we want to split column 'list' in table lists into separate rows using the comma as the delimiter. Table lists id list 1 aa,bbb,c 2 e,f,gggg,hh 3 ii,kk 4 m
2
by: cynthiav | last post by:
Hello, I am working on a query in Access 2003. I have multiple rows of data like below: Ord # date description time 1 11/7/06 chocolate ...
2
nehashri
by: nehashri | last post by:
i hv a database in access wid Asp as front end. ven given a word in search command(of the front end) it shud go to a table in which each field has words serated by comma. each word shud b checked...
4
nehashri
by: nehashri | last post by:
i want to knw how Search for text within single file in Ms Access, i have my data seperated by commas in the columns....... how do i query through the file for single word. like for example i want...
0
by: Kristi | last post by:
I need to create a CL program that will take a PF, and create a tab delimited file that has comma seperated column headings as the first record. I know i can use cpytostmf/cpytoimpf to create the...
1
by: chris f | last post by:
I'm dynamically populating a Table control in ASP.NET 2. Each row has 4 columns but column #3 needs to be split into 3 rows and column #4 needs to be split into 4 rows. Each of these cells contains...
6
by: orajit | last post by:
Hi, I wanted to list the all columns of a emp table . The output should be comma seperated and list of column should come in brakets like (enam,sal,jdate,job). The below code gives me proper...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.