Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Help with select to convert ref ID to full name
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Constraint Violating Yak Guru

424 Posts

Posted - 10/16/2012 :  18:40:53  Show Profile  Visit Eagle_f90's Homepage  Reply with Quote
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 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.

Almighty SQL Goddess

38200 Posts

Posted - 10/16/2012 :  19:18:33  Show Profile  Visit tkizer's Homepage  Reply with Quote
Please show us a data example of what you mean. The DDL is very helpful, but we need sample data too.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server

Subscribe to my blog
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.5 seconds. Powered By: Snitz Forums 2000