karthik555
IS-IT--Management
Hi!
I have data as below
CREATE TABLE #Input (OldAsset Char(20), CurrAsset Char(20), Status Char(3), InpSrlNo INT Identity(1,1), GUID uniqueidentifier, InpProcstat char(1))
DECLARE @GUID Uniqueidentifier
SELECT @GUID = NewID()
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A1', 'A2', 'CAN', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A1', 'A2', 'CON', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A1', 'A3', 'CON', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A3', 'A4', 'CON', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A4', 'A5', 'CON', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A5', 'A6', 'CON', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A6', 'A7', 'CON', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A7', 'A8', 'CON', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A8', 'A9', 'CON', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A9', 'A10', 'CON', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A10', 'A11', 'CAN', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A10', 'A11', 'CON', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A11', 'A8', 'CON', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A8', 'A10', 'CAN', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A8', 'A10', 'CON', @GUID, 'N')
go
This is nothing but change of name of an asset over a period of time.
IF the user gives any Asset (as CurrAsset) then I have to write a query to find all the changes it has undergone.
In the above example, if the user gives A10, then I have to display all the rows. (ProcStatus and GUID are for processing purpose only. I need to display only the first three columns)
However there can be other rows belonging to other asset in the table as well.
Tried with expanding hierarchy concept. Doesn't work eactly.
If anyone has any idea how to go about, it will be great help.
Thanks in advance..
Karthik
I have data as below
CREATE TABLE #Input (OldAsset Char(20), CurrAsset Char(20), Status Char(3), InpSrlNo INT Identity(1,1), GUID uniqueidentifier, InpProcstat char(1))
DECLARE @GUID Uniqueidentifier
SELECT @GUID = NewID()
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A1', 'A2', 'CAN', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A1', 'A2', 'CON', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A1', 'A3', 'CON', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A3', 'A4', 'CON', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A4', 'A5', 'CON', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A5', 'A6', 'CON', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A6', 'A7', 'CON', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A7', 'A8', 'CON', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A8', 'A9', 'CON', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A9', 'A10', 'CON', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A10', 'A11', 'CAN', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A10', 'A11', 'CON', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A11', 'A8', 'CON', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A8', 'A10', 'CAN', @GUID, 'N')
INSERT INTO #Input (OldAsset, CurrAsset, Status, GUID, InpProcStat)
VALUES
('A8', 'A10', 'CON', @GUID, 'N')
go
This is nothing but change of name of an asset over a period of time.
IF the user gives any Asset (as CurrAsset) then I have to write a query to find all the changes it has undergone.
In the above example, if the user gives A10, then I have to display all the rows. (ProcStatus and GUID are for processing purpose only. I need to display only the first three columns)
However there can be other rows belonging to other asset in the table as well.
Tried with expanding hierarchy concept. Doesn't work eactly.
If anyone has any idea how to go about, it will be great help.
Thanks in advance..
Karthik