DIR Return Create A Forum - Home
---------------------------------------------------------
ExcelSoft Database Professionals
HTML https://esdbp.createaforum.com
---------------------------------------------------------
*****************************************************
DIR Return to: Scripts
*****************************************************
#Post#: 45--------------------------------------------------
Table Hirerarchy
DIR By: srinivasma_exceldbp
Date: April 10, 2014, 9:49 pm
---------------------------------------------------------
--** Table Hierarchy with Hierarchy Levels .
SET NOCOUNT ON
DECLARE
@intCounter
@intRowCount
--========================================================
IF OBJECT_ID('tempdb..#Hierarchy') IS NOT NULL
DROP TABLE
CREATE TABLE #Hierarchy
(
Hierarchy
Child
Parent
)
--========================================================
-- Set the variables
SELECT @intCounter
SELECT @intRowCount = 1
--========================================================
-- Populate the table
INSERT INTO #Hierarchy ( Hierarchy,Child,Parent)
SELECT DISTINCT 1 AS 'Hierarchy', S1.name AS 'Child', SO.Name AS
'Parent'
FROM dbo.sysforeignkeys FK
INNER JOIN dbo.sysobjects SO
ON FK.rkeyID = SO.id
INNER JOIN dbo.sysobjects S1
ON FK.fkeyID = S1.id
--========================================================
WHILE @intRowCount <> 0
BEGIN
UPDATE P SET
gopher.createaforum.com:70 /forums/esdbp/p/43:46: port field too long