Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2009

    Unanswered: Simple Query Debug Help

    Basically Im playing around with databases in SQL Server to help learn the language. Is there anything wrong with this command? Basically I have two tables from different table groups on the same database.

    Essentially there is one table in each, for my problem's sake, tblA, tblB on groups A and B.

    tblA consists {LastName, FirstName}
    tblB consists {LastName, FirstName}

    tblA consists of some last names that are the same as tblB and im trying to query those names that have the same last name from both tables and list them

    is this right?

    SELECT A.tblA.LastName AS ALastName, A.tblA.FirstName AS AFirstName, B.tblB.LastName AS BLastName, BA.tblB.FirstName AS BFirstName
    FROM tblA JOIN tblB ON A.tblA.LastName = B.tblB.LastName

  2. #2
    Join Date
    Jan 2003
    Provided Answers: 11
    If you are talking about Filegroups in a database, then you do not need to specify that in the query. Only the schema name, and possibly the database name would need to be specified to qualify a table. Try this:
    SELECT tblA.LastName AS ALastName, 
        tblA.FirstName AS AFirstName, 
        tblB.LastName AS BLastName, 
        tblB.FirstName AS BFirstName
    FROM tblA JOIN 
        tblB ON tblA.LastName = tblB.LastName

  3. #3
    Join Date
    Sep 2009
    Not 100% sure about what is shown as a filegroup, but say im ripping data from AdventureWorks and AdventureWorksDW, are those two different filegroups on the same database?

    EDIT: AdventureWorks is the MS sample database im playing with

    EDIT: Any Faster Way to do this? without using JOIN? for instance I increase my name to 15 million names on one and 20 on the other

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts