November 15, 2004 at 11:52 am
I have a table in a database that has very old and not very relational and I want to create a quick view to show the information in a better way. Let's say that the table has 4 fields : id , child1, child2, child3. I want to create a view from this table that will show two fields : id and child. So, my table currently looks like this:
id child1 child2 child3
1 sam bob chris
and i would like it like this......
id child
1 sam
1 bob
1 chris
Can anybody help me? Thanks in advance,
Bob
November 15, 2004 at 2:24 pm
ALTER VIEW [dbo].YourView AS
SELECT [id],Child1 FROM Table1
******************
Dinakar Nethi
Life is short. Enjoy it.
******************
November 15, 2004 at 5:12 pm
You'd need a union for each column. ie:
CREATE VIEW [dbo].[NiceChildren] As,
SELECT [ID], Child1 FROM [dbo].[Children]
UNION ALL
SELECT [ID], Child2 FROM [dbo].[Children]
UNION ALL
SELECT [ID], Child3 FROM [dbo].[Children]
UNION ALL
SELECT [ID], Child4 FROM [dbo].[Children]
November 15, 2004 at 5:30 pm
thank you Shaunio for the help....works like a charm.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply