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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Creating multiple records from single records.

Author  Topic 

JohnMcLaughlin
Starting Member

28 Posts

Posted - 2010-10-28 : 10:00:11
I have a table that looks like this

col1 col2 col3 Col4
R5 1 2 3
R6 1 2 3

and i want to be able to make it look like this

col1 col2
R5 1
R5 2
R5 3
R6 1
R6 2
R6 3

I want to be able to split the one record into multiple records.

Any help would be much appreciated

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-10-28 : 10:03:04
Maybe this:
SELECT col1,col2 FROM YourTable UNION ALL
SELECT col1,col3 FROM YourTable UNION ALL
SELECT col1,col4 FROM YourTable



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

JohnMcLaughlin
Starting Member

28 Posts

Posted - 2010-10-28 : 10:29:17
It's saying 'Views containing Unions cannot be represented graphically in the Grid and Diagram panes'.

I want to be able to use this in a view. Is there a way of making this into a table and then i can use it in a view?
Go to Top of Page
   

- Advertisement -