I have a table that referances it's self and was hoping to get help building a SELECT statment that will convert the an ID to full name. The ID is contacned in ParentLocaiton and it referanced LocationID, the full name is contained in LocationName. My table is:
CREATE TABLE dbo.tblLocations
LocationID int IDENTITY(0,1) NOT NULL,
LocationName varchar(250) NOT NULL,
SectionID smallint NOT NULL,
LocationType smallint NOT NULL,
ParentLocation int NULL,
MapFileID int NULL,
CONSTRAINT PK_Locations_LocationID PRIMARY KEY CLUSTERED (LocationID ASC),
CONSTRAINT FK_Locations_SectionID FOREIGN KEY (SectionID) REFERENCES dbo.tblSectionInfo (SectionID),
CONSTRAINT FK_Locations_LocationType FOREIGN KEY (LocationType) REFERENCES dbo.tblLocationTypes (LocationTypeID),
CONSTRAINT FK_Locations_ParentLocation FOREIGN KEY (ParentLocation) REFERENCES dbo.tblLocations (LocationID),
CONSTRAINT FK_Locations_MapFileID FOREIGN KEY (MapFileID) REFERENCES dbo.tblFiles (FileID)
If I get used to envying others...
Those things about my self I pride will slowly fade away.