Click here to Skip to main content
15,501,747 members
Home / Discussions / Database
   

Database

 
AnswerRe: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER Pin
Eddy Vluggen16-Jul-14 6:03
professionalEddy Vluggen16-Jul-14 6:03 
AnswerRe: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER Pin
PIEBALDconsult17-Jul-14 14:39
professionalPIEBALDconsult17-Jul-14 14:39 
QuestionExtract Data in Single Record Pin
mrfalk15-Jul-14 14:05
Membermrfalk15-Jul-14 14:05 
AnswerRe: Extract Data in Single Record Pin
data modeling guy15-Jul-14 20:32
Memberdata modeling guy15-Jul-14 20:32 
AnswerRe: Extract Data in Single Record Pin
Richard Deeming16-Jul-14 3:42
mveRichard Deeming16-Jul-14 3:42 
AnswerRe: Extract Data in Single Record Pin
PIEBALDconsult17-Jul-14 14:54
professionalPIEBALDconsult17-Jul-14 14:54 
Questionlinked list using CTE Pin
Ali Al Omairi(Abu AlHassan)14-Jul-14 23:29
professionalAli Al Omairi(Abu AlHassan)14-Jul-14 23:29 
AnswerRe: linked list using CTE Pin
Ali Al Omairi(Abu AlHassan)15-Jul-14 0:14
professionalAli Al Omairi(Abu AlHassan)15-Jul-14 0:14 
finally, i designed a query that returns the desired results. its the following one.

SQL
create table products(product_id int, next_id int, product_name nvarchar(50));
insert into products(product_id, next_id, product_name)
Values (1, null, N'product1')
,(2, 4, N'product2')
,(3, 2, N'product3')
,(4, 1, N'product4')
,(5, 3, N'product5');

WITH LinkedList (product_id, next_id, product_name, Level)
AS
(
-- Anchor member definition
    SELECT e.product_id, e.next_id, e.product_name, 
        0 AS Level
    FROM products AS e
    WHERE e.next_id IS NULL
    UNION ALL
-- Recursive member definition
    SELECT e.product_id, e.next_id, e.product_name,
        Level + 1
    FROM products AS e
    INNER JOIN LinkedList AS d
        ON e.next_id = d.product_id
)
-- Statement that executes the CTE
SELECT product_id, next_id, product_name
FROM LinkedList
Order by Level desc;

drop Table products;

Help people,so poeple can help you.

QuestionOVER (PARTITION BY ORDER BY ) Pin
Ambertje14-Jul-14 5:44
MemberAmbertje14-Jul-14 5:44 
AnswerRe: OVER (PARTITION BY ORDER BY ) Pin
PIEBALDconsult14-Jul-14 6:13
professionalPIEBALDconsult14-Jul-14 6:13 
GeneralRe: OVER (PARTITION BY ORDER BY ) Pin
Ambertje14-Jul-14 6:15
MemberAmbertje14-Jul-14 6:15 
AnswerRe: OVER (PARTITION BY ORDER BY ) Pin
Eddy Vluggen14-Jul-14 6:27
professionalEddy Vluggen14-Jul-14 6:27 
GeneralRe: OVER (PARTITION BY ORDER BY ) Pin
PIEBALDconsult14-Jul-14 6:29
professionalPIEBALDconsult14-Jul-14 6:29 
QuestionRe: OVER (PARTITION BY ORDER BY ) Pin
Eddy Vluggen14-Jul-14 8:47
professionalEddy Vluggen14-Jul-14 8:47 
AnswerRe: OVER (PARTITION BY ORDER BY ) Pin
Jörgen Andersson14-Jul-14 9:33
professionalJörgen Andersson14-Jul-14 9:33 
GeneralRe: OVER (PARTITION BY ORDER BY ) Pin
Mycroft Holmes14-Jul-14 13:54
professionalMycroft Holmes14-Jul-14 13:54 
GeneralRe: OVER (PARTITION BY ORDER BY ) Pin
Jörgen Andersson14-Jul-14 23:20
professionalJörgen Andersson14-Jul-14 23:20 
GeneralRe: OVER (PARTITION BY ORDER BY ) Pin
Ambertje14-Jul-14 23:12
MemberAmbertje14-Jul-14 23:12 
AnswerRe: OVER (PARTITION BY ORDER BY ) Pin
jschell14-Jul-14 11:07
Memberjschell14-Jul-14 11:07 
AnswerRe: OVER (PARTITION BY ORDER BY ) Pin
GuyThiebaut14-Jul-14 22:33
professionalGuyThiebaut14-Jul-14 22:33 
GeneralRe: OVER (PARTITION BY ORDER BY ) Pin
Ambertje14-Jul-14 23:13
MemberAmbertje14-Jul-14 23:13 
QuestionError: Can't delete row or update row in SQL Server ? Pin
taibc11-Jul-14 19:29
Membertaibc11-Jul-14 19:29 
AnswerRe: Error: Can't delete row or update row in SQL Server ? Pin
Mycroft Holmes12-Jul-14 0:32
professionalMycroft Holmes12-Jul-14 0:32 
GeneralRe: Error: Can't delete row or update row in SQL Server ? Pin
taibc13-Jul-14 21:36
Membertaibc13-Jul-14 21:36 
GeneralRe: Error: Can't delete row or update row in SQL Server ? Pin
Mycroft Holmes13-Jul-14 22:06
professionalMycroft Holmes13-Jul-14 22:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.