Referencing tables in another Numbers '09 file

Is there a way to reference table in another Numbers file. For example using the VLOOKUP formula to bring data from another Numbers file into my current table. I was wondering if you have to have that table in the same Numbers file. My Tables are in the thousands and and have 3 alphabets of columns and it would be difficult to fit 2 of those onto my screen in the same Numbers file.

Not from another file, only from within the same document. Numbers does not support external links to other spreadsheet files.

Similar Messages

  • Can I link to a table in another Numbers file?

    I have searched through the documentation and on support and cannot find a way that I can reference a cell belonging to another Numbers file. I essentially want to use one Numbers file to store a very large amount of data and have separate smaller files access that data. So far I have only been able to link to cells on a different sheet in the SAME Numbers document.
    iWork Pages allows me to link to a Numbers docuement table so I was hoping to find a similar capability within Numbers itself.
    Karen

    That feature is unavailable. A search of this forum on the word "link" will provide numerous questions on the same subject. It is obviously a highly desired feature.

  • Referencing cells in other numbers spreadsheet files

    A couple of questions:
    1)I have two sheets (Sheet A and Sheet b) in the same file. Both sheets have a single table named Table 1 in them. I can double tap on a cell in Sheet A Table 1, tap on the equal sign in the entry box. I can then go to Sheet B Table 1 and double tap on a cell. Numbers inserts a reference of Sheet B::Table 1::Col Row. I can now change the value in Sheet B and Sheet A updates automatically. My question is can I type in the reference to the cell in Sheet B and not do all the finger tapping?
    2)Can I type in a reference to another cell in a table on a sheet in another Numbers file located on my iPad. If not is there a way to tap to the reference?

    I have had no luck typing in any formulas in iPad numbers directly. I can do it using the desktop version, but not the iPad. I found I had to do all the finger tapping the op mentions. Even to type simple formulas that I know how to do by heart, I had to search the function list and select the item from the list.
    If I use the keyboard that comes up within the equation editor it places everything in quotes and sees it as text. Which doesn't invert to the actual equation. If I use the text input and type an equal sign with the equation it still sees it only as text.
    If you know how to do the typing thing, please give us more in depth instructions on how to do this in numbers for iPad as that would be beneficial to a degree you annotate fathom.
    Referencing the other file thing doesn't work in desktop at all, so thi is only reefing to how to get to type in my formuas by hand in. Single file, referring to a single file in iPad numbers.
    Thanks
    Jason

  • Need an applecript to copy filtered cells from a Numbers table to another Numbers file

    Hi,
    I would like to be able to build a new table in an existing file based on a filtered selection.
    My file covers the whole year and have many more columns but let's make a short example:
    Starting table: Table 1 Sheet 1 file 1
    Date
    Quantity
    Price
    Action
    Port
    10/3/2014
    1050
    100
    IN
    Venice
    11/3/2014
    35
    104
    CES
    Venice
    16/3/2014
    2045
    90
    IN
    Barcelona
    21/3/2014
    545
    9
    CUS
    Barcelona
    25/3/2014
    50
    123
    CES
    Venice
    28/3/2014
    50
    21
    CUS
    Rome
    I would like to have on a separte file(table 1 Sheet 3 File 2) a table like this (filtered by Action: IN + CUS and Port: Venice + Barcelona)
    Date
    Quantity
    Price
    Action
    Port
    10/3/2014
    1050
    100
    IN
    Venice
    16/3/2014
    2045
    90
    IN
    Barcelona
    21/3/2014
    545
    9
    CUS
    Barcelona
    Any help?

    Although I would have preferred to have a script beacuse the data origin file - let's call it STORAGE - is already quite heavy and I would like to use the filtered data on a separate file - let's call it MANAGEMENT - for further analysis and integration with other data coming from other STORAGE files and from other company areas.
    Hi Paolo,
    Below is a script that should do what you want. (Tested in Numbers 3.2). Copy into AppleScript Editor, set up the Numbers documents as indicated (or change the script to match your document setup), and click the green triangle 'Run' button.
    It assumes you have both the source document ("Storage.numbers") and target document ("Management.numbers") open and that you have already set up the target table with 1 header row.  You can change your filter columns and values and filter logic where indicated.
    For simplicity (and also to avoid apparent Numbers bugs in removing rows via AppleScript) I assumed the user will manually check to make sure that the target table does not contain too many rows. It needs at least 2 rows to work properly as the results are inserted starting in cell A2 (which can be changed as needed).
    SG
    --filters a table and passes the results to an existing table in the same or different document
    --set filter column and values to filter for here:
    property filter1 : {colNum:4, filterFor:{"CUS", "IN"}}
    property filter2 : {colNum:5, filterFor:{"Barcelona", "Venice"}}
    --set properties of source's and target's document, sheet, table here:
    property source : {d:"Storage.numbers", s:"Sheet 1", t:"Table 1"}
    property target : {d:"Management.numbers", s:"Sheet 1", t:"Table 1"}
    tell application "Numbers"
              activate
              set filteredList to {}
               --load source table's values into a list of lists
              try
                        set valuesList to value of document (source's d as string)'s ¬
                                  sheet (source's s as string)'s table (source's t as string)'s ¬
                                 rows's cells
              on error
                        display dialog "Having trouble. Does your source document, sheet, and table exist?"
              end try
               --create filtered list of lists
              tell valuesList to repeat with anItem in items
                        --if needed, logic can be changed to 'not in', etc.
                        set satisfiesFilter1 to anItem's item (filter1's colNum) is in filter1's filterFor
                        set satisfiesFilter2 to anItem's item (filter2's colNum) is in filter2's filterFor
                        --if needed, logic can be changed here to 'or', etc.
                        if satisfiesFilter1 and satisfiesFilter2 then ¬
                                  copy anItem's items to end of filteredList
              end repeat
              if (count filteredList) = 0 then display dialog "No rows meet your criteria" buttons "Cancel"
               --load values into target table (in this or another document, as specified in properties above)
              try
                        tell document (target's d as string)'s sheet (target's s as string)'s ¬
                                  table (target's t as string)
                                 --load the values into the cells starting at cell A2:
                                  set pasteStr to ""
                                  set {oTid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, tab}
                                  repeat with anItem in filteredList's items
                                            set pasteStr to (pasteStr & anItem as string) & return
                                  end repeat
                                  set the clipboard to pasteStr
                                  set the selection range to cell "A2" --assumes 1 header row
                                  tell application "System Events" to keystroke "v" using {option down, shift down, command down}
                        end tell
              on error
                        display dialog "Having trouble. Does your target (destination) document, sheet, and table exist?"
              end try
    end tell
    --end of script

  • Autocomplete from another table in another sheet in same file

    I found how to get a price to autofill using VLOOKUP. I like it.
    Now, I want to be lazier and not need to type in the full item name in the row heading completely & exactly every time. I also don't want to have a drop down menu in every item line in each table unless there is no better alternative. I would like Numbers to autofill from an inventory list (table with quantities, prices, etc.) in another sheet. It seems that I should have been able to find this function explained but my searches were inadequate.
    Then, I will want Numbers to automatically update another column in the inventory table with the quantity of that item sold & the amount remaining which will cause calculations for the value remaining & sold in other columns (without changing the original inventory column). It seems to me that the formula may require numbers to search each table in each sheet for the item name in that row and add all sale quantities together. This means that the formulas would be constantly searching which sounds like it could slow things down a bit. So, again, maybe there's a more efficient way of doing this.
    Please help me find these efficiency tools. ThankU

    Mr. "P" wrote:
    I want to copy an entire row from one table in one sheet to another table in another sheet retaining all values and formulas? So that if I make a change in the original sheet it propagates to the other sheet
    (1) A change in the original will propagate to the other table if the change is in the 'copied' row.
    (2) what you require can't be achieve by a copy process.
    It requires the use of external references which are perfectly described in the User Guide (page 122 in the English version).
    (3) sure, a reference is a cell's attribute so you will have to enter it in every cell of the row.
    When it's done for one row you may use the Fill Down tool which is also described (with quite all you need to use Numbers) in the User Guide.
    Yvan KOENIG (from FRANCE vendredi 19 juin 2009 15:53:03)

  • Table 2 Cel A1 Referencing Table 1 Cel A1

    Hi,
    I must be missing something...
    I have 2 tables set up on the same sheet in Numbers 09. I set A1 in Table 2 to equal A1 in Table 1. Now if I add a row above Row A in Table 1, my A1 in Table 2 = Table 1 A2. I've tried playing with the Relative and Absolute selections in the function to no avail. How do I specify that a cel in a table always equals the same cel in another table no matter what is done to the referenced table?
    Thanks!

    You use INDIRECT.
    Table 2 A1 = INDIRECT("Table 1::A1")
    or if you want to make it easier to fill in an entire row
    A1 =INDIRECT(ADDRESS(ROW(),COLUMN(),,,"Table 1"))
    You can take this second formula and fill it across/down. The first formula you would have to edit for each cell.

  • Adding Data From One Table to Another

    Now, this doesn't strike me as a particularly complex problem, but I've either strayed outside the domain of Numbers or I'm just not looking at the problem from the right angle. In any case, I'm sure you guys can offer some insight.
    What I'm trying to do is, essentially, move data from one table to another. One table is a calendar, a simple two column 'date/task to be completed' affair, the other is a schedule of jogging workouts, i.e, times, distances. Basically, I'm trying to create a formula that copies data from the second table onto the first but only for odd days of the week, excepting Sundays (and assuming Monday as the start of the week). Now, this isn't the hard part, I can do that. The problem comes when I replicate the formula down the calendar. Even on the days when the 'if' statement identifies it as an 'even day', the cell reference to the appropriate workout on the second table is incremented, so when it comes to the next 'odd day', it has skipped a workout.
    I can't seem to see any way of getting it to specifically copy the NEXT line in the second table, and not the corresponding line.
    This began as a distraction to try and organise my running so I could see at a glance what I had to do that day and track my progress, but now it's turned into an obsession. SURELY there's a solution?
    Cheers.

    Hi Sealatron,
    Welcome to Apple Discussions and the Numbers '09 forum.
    Several possible ways to move the data occur to me, but the devil's in the details of how the data is currently arranged.
    Is it
    • a list of three workouts, one for each of Monday, Wednesday and Friday, then the same three repeated the following week?
    • an open-ended list that does not repeat?
    • something else?
    Regards,
    Barry

  • Insert old missing data from one table to another(databaase trigger)

    Hello,
    i want to do two things
    1)I want to insert old missing data from one table to another through a database trigger but it can't be executed that way i don't know what should i do in case of replacing old data in table_1 into table_2
    2)what should i use :NEW. OR :OLD. instead.
    3) what should i do if i have records exising between the two dates
    i want to surpress the existing records.
    the following code is what i have but no effect occured.
    CREATE OR REPLACE TRIGGER ATTENDANCEE_FOLLOWS
    AFTER INSERT ON ACCESSLOG
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    V_COUNT       NUMBER(2);
    V_TIME_OUT    DATE;
    V_DATE_IN     DATE;
    V_DATE_OUT    DATE;
    V_TIME_IN     DATE;
    V_ATT_FLAG    VARCHAR2(3);
    V_EMP_ID      NUMBER(11);
    CURSOR EMP_FOLLOWS IS
    SELECT   EMPLOYEEID , LOGDATE , LOGTIME , INOUT
    FROM     ACCESSLOG
    WHERE    LOGDATE
    BETWEEN  TO_DATE('18/12/2008','dd/mm/rrrr') 
    AND      TO_DATE('19/12/2008','dd/mm/rrrr');
    BEGIN
    FOR EMP IN EMP_FOLLOWS LOOP
    SELECT COUNT(*)
    INTO  V_COUNT
    FROM  EMP_ATTENDANCEE
    WHERE EMP_ID    =  EMP.EMPLOYEEID
    AND    DATE_IN   =  EMP.LOGDATE
    AND    ATT_FLAG = 'I';
    IF V_COUNT = 0  THEN
    INSERT INTO EMP_ATTENDANCEE (EMP_ID, DATE_IN ,DATE_OUT
                                ,TIME_IN ,TIME_OUT,ATT_FLAG)
         VALUES (TO_NUMBER(TO_CHAR(:NEW.employeeid,99999)),
                 TO_DATE(:NEW.LOGDATE,'dd/mm/rrrr'),       -- DATE_IN
                 NULL,
                 TO_DATE(:NEW.LOGTIME,'HH24:MI:SS'),      -- TIME_IN
                 NULL ,'I');
    ELSIF   V_COUNT > 0 THEN
    UPDATE  EMP_ATTENDANCEE
        SET DATE_OUT       =  TO_DATE(:NEW.LOGDATE,'dd/mm/rrrr'), -- DATE_OUT,
            TIME_OUT       =   TO_DATE(:NEW.LOGTIME,'HH24:MI:SS'), -- TIME_OUT
            ATT_FLAG       =   'O'
            WHERE EMP_ID   =   TO_NUMBER(TO_CHAR(:NEW.employeeid,99999))
            AND   DATE_IN <=  (SELECT MAX (DATE_IN )
                               FROM EMP_ATTENDANCEE
                               WHERE EMP_ID = TO_NUMBER(TO_CHAR(:NEW.employeeid,99999))
                               AND   DATE_OUT IS NULL
                               AND   TIME_OUT IS NULL )
    AND   DATE_OUT  IS NULL
    AND   TIME_OUT IS NULL  ;
    END IF;
    END LOOP;
    EXCEPTION
    WHEN OTHERS THEN RAISE;
    END ATTENDANCEE_FOLLOWS ;
                            Regards,
    Abdetu..

    INSERT INTO SALES_MASTER
       ( NO
       , Name
       , PINCODE )
       SELECT SALESMANNO
            , SALESMANNAME
            , PINCODE
         FROM SALESMAN_MASTER;Regards,
    Christian Balz

  • Creating a "Print View" of a Table on Another Sheet

    Hi-
    I would like to create a "print view" of a table on another sheet that already has reorganization filters applied to it.  There is a template in Numbers called "Employee Schedule" that has exactly this, where the "printable" table's cells simply reference every cell in the source table on the other sheet.
    I know there is a way to very quickly (i think with a dragging motion), create the references in each cell in one or two operations, as opposed to going to each individual cell and typing in the reference to the source table.  I saw a post about how to do this a while back but cannot seem to locate it again
    How do I do this?  Thanks again for everyones help ;-)
    Thanks
    Matt

    mattford1 wrote:
    Hi-
    Re-reading this, I don't think this answered my question.  I understand how to reference a single cell, but how do you reference an entire table easily without having to go to each cell.
    Thanks
    Matt
    Matt,
    Select the first cell by clicking once on it, such that the border is highlighted. Then grab the little circle in the lower right corner of the border and drag it to the end of your table, either right or down. You can use this method to fill down or to the right. Sometimes it can be fussy, and if it refuses to behave, then you can use the alternate method, Copy and Paste. Click once on the first cell and Command-C. Shift-click the last cell and Command-V.
    Jerry

  • Flowing data from one Table to another

    I am new to Numbers and I am having a hard time figuring out how to flow a sum from one table into another table. Is this possible? Please help.
    Thanks
    E

    lassiegirl wrote:
    I am new to Numbers and I am having a hard time figuring out how to flow a sum from one table into another table. Is this possible? Please help.
    Hi lassiegirl,
    Welcome to Apple Discussions and the Numbers '09 forum.
    Apple provides two excellent resources that I recommend be downloaded by all Numbers users, the Numbers '09 User Guide and the iWork Formulas and Functions User Guide. You'll find linke for both of them in the Help menu in Numbers.
    The first will give you an overview of Numbers and how it works—spend some time with the preface and the first chapter, browse the rest on a need to know basis when you're doing something new. The second is a reference, useful when you're trying to write a formula.
    To your question...
    You can copy the sum from one table to another.
    For the example formula beow, both Table 1 and Table 2 have one header row and one footer row, and a total of 21 rows each.
    If the SUM on Table 1 is in cell C21, and you want to include it in the SUM of column C in Table 2, you could transfer the sum to C1 in the header row of Table 2 with:
    C1:  =Table 1::C21
    In C21 of Table 2 (a Footer row), use any of these formulas:
    =SUM(C)+C1
    =SUM(Table 1::C)+SUM(C)
    =SUM(Table 1 :: C,C)
    The first calculates the sum of the cells in column C (of its own table—Table 2) and adds the value in C1, the total transferred from Table 1.
    The second returns the same result by calculating the sums of the two columns separately, then adding those sums.
    The third takes the single arguments of the two SUM statements in the second, and lists them as multiple arguments in a single SUM statement.
    Regards,
    Barry

  • How to load color table in a indexed mode file??

    How to load color table in a indexed mode file??
    Actually, if i opened a indexed file and want to edit color table by loading another color table from desktop (or any other location), any way to do this through java scripting??

    continuing...
    I wrote a script to read a color table from a GIF file and save to an ACT color table file. I think it might be useful for someone.
    It goes a little more deeper than the code I posted before, as it now identifies the table size. It is important because it tells how much data to read.
    Some gif files, even if they are saved with a reduced palette (less than 256), they have all the bytes for the full color palette filled inside the file (sometimes with 0x000000). But, some gif files exported in PS via "save for web" for example, have the color table reduced to optimize file size.
    The script store all colors into an array, allowing some kind of sorting, or processing at will.
    It uses the xlib/Stream.js in xtools from Xbytor
    Here is the code:
    // reads the color table from a GIF image
    // saves to an ACT color table file format
    #include "xtools/xlib/Stream.js"
    // read the 0xA byte in hex format from the gif file
    // this byte has the color table size info at it's 3 last bits
    Stream.readByteHex = function(s) {
      function hexDigit(d) {
        if (d < 10) return d.toString();
        d -= 10;
        return String.fromCharCode('A'.charCodeAt(0) + d);
      var str = '';
      s = s.toString();
         var ch = s.charCodeAt(0xA);
        str += hexDigit(ch >> 4) + hexDigit(ch & 0xF);
      return str;
    // hex to bin conversion
    Math.base = function(n, to, from) {
         return parseInt(n, from || 10).toString(to);
    //load test image
    var img = Stream.readFromFile("~/file.gif");
    hex = Stream.readByteHex(img);      // hex string of the 0xA byte
    bin = Math.base(hex,2,16);          // binary string of the 0xA byte
    tableSize = bin.slice(5,8)          // Get the 3 bit info that defines size of the ct
    switch(tableSize)
    case '000': // 6 bytes table
      tablSize = 2
      break;
    case '001': // 12 bytes table
      tablSize = 4
      break;
    case '010': // 24 bytes table
      tablSize = 8
      break;
    case '011': // 48 bytes table
      tablSize = 16
      break;
    case '100': // 96 bytes table
      tablSize = 32
      break;
    case '101': // 192 bytes table
      tablSize = 64
      break;
    case '110': // 384 bytes table
      tablSize = 128
      break;
    case '111': // 768 bytes table
      tablSize = 256
      break;
    //========================================================
    // read a color (triplet) from the color lookup table
    // of a GIF image file | return 3 Bytes Hex String
    Stream.getTbColor = function(s, color) {
      function hexDigit(d) {
        if (d < 10) return d.toString();
        d -= 10;
        return String.fromCharCode('A'.charCodeAt(0) + d);
      var tbStart = 0xD; // Start of the color table byte location
      var colStrSz = 3; // Constant -> RGB
      var str = '';
      s = s.toString();
         for (var i = tbStart+(colStrSz*color); i < tbStart+(colStrSz*color)+colStrSz; i++) {
              var ch = s.charCodeAt(i);
              str += hexDigit(ch >> 4) + hexDigit(ch & 0xF);
          return str;
    var colorHex = [];
    importColors = function (){
         for (i=0; i< tablSize; i++){ // number of colors
              colorHex[i] = Stream.getTbColor(img, i);
    importColors();
    // remove redundant colors
    // important to determine exact color number
    function unique(arrayName){
         var newArray=new Array();
         label:for(var i=0; i<arrayName.length;i++ ){ 
              for(var j=0; j<newArray.length;j++ ){
                   if(newArray[j]==arrayName[i])
                        continue label;
              newArray[newArray.length] = arrayName[i];
         return newArray;
    colorHex = unique(colorHex);
    // we have now an array with all colors from the table in hex format
    // it can be sorted if you want to have some ordering to the exported file
    // in case, add code here.
    var colorStr = colorHex.join('');
    //=================================================================
    // Output to ACT => color triplets in hex format until 256 (Adr. dec 767)
    // if palette has less than 256 colors, is necessary to add the
    // number of colors info in decimal format to the the byte 768.
    ColorNum = colorStr.length/6;
    lstclr = colorStr.slice(-6); // get last color
    if (ColorNum < 10){
    ColorNum = '0'+ ColorNum;
    cConv = function (s){
         var opt = '';
         var str = '';
         for (i=0; i < s.length ; i++){
              for (j=0; j<2 ; j++){
                   var ch = s.charAt(i+j);
                   str += ch;
                   i ++;
              opt += String.fromCharCode(parseInt(str,16));
              str = '';
         return opt
    output = cConv(colorStr);
    // add ending file info for tables with less than 256 colors
    if (ColorNum < 256){
         emptyColors = ((768-(colorStr.length/2))/3);
         lstclr = cConv(lstclr);
         for (i=0; i < emptyColors ; i++){
              output += lstclr; // fill 256 colors
    output += String.fromCharCode(ColorNum) +'\xFF\xFF'; // add ending bytes
    Stream.writeToFile("~/file.act", output);
    PeterGun

  • Best practice: self referencing table

    Hallo,
    I want to load a self referencing table to my enterprise area in the dwh. I am not sure how to do this. What if a record references to another record which is inserted later in the same etl process? There is now way to sort, because it is possible that record a references to record b and record b references to record a. Disabling the fk constraint is not a good idea, because this doesn't prevent that invalid references will be loaded? I am thinking of building two mappings, one without the self referencing column and the other only with it, but that would cause approx. twice as much running time. Any other solutions?
    Regards,
    Torsten

    Mind sharing the solution? Would be interested to hear your solution (high level).
    Jean-Pierre

  • How to move records from one table to another?

    Is there a way to copy data and column names from one table to another table?
    I am trying to copy one production database table onto the development database. we are using Oracle 10g. I tried exporting to an xls file and importing to the other table but this needs to create destination table with the column names. Is there any better approach to achieve this?

    Hello,
    You can create dblink between production and dev and from dev just
    *1. create table mytable as select * from mytable@dblink;**2. Use of export/import or datapump*
    Example
       On prod
       exp username/password tables=mytable1,mytable2 file=mytableexport.dmp log=mytableexport.log
       On dev
       imp username/password tables=mytable1,mytable2 file=mytableexport.dmp log=mytableimport.log*3. Datapump*
    http://www.oracle-base.com/articles/10g/OracleDataPump10g.php
    *4. Generate csv formatted file and use sqlldr or external*
    External Table: http://www.adp-gmbh.ch/ora/misc/ext_table.html
    Sqlldr: http://www.psoug.org/reference/sqlloader.html
    Regards
    Edited by: OrionNet on Feb 13, 2009 6:52 PM

  • Using tables from another app

    Hi
    I have little experience developing multi-app systems.
    In this specific case, I have a table that has a FK for a table in another app.
    My first question is: if I export the referencing app, and import it in another repository that hasn't the referenced app, what happens? The import fails? Should I import the referenced app first?
    My 2nd question: since the two apps will correspond to different database schemas, how am I supposed to generate the DB? Specifically how to generate that FK that points to a table in another schema...
    Thanks
    Luis Cabral

    I meant when I go to the app store through an app like Flipboard.

  • Ms sql - {"The referenced table must have a primary or candidate key. [ FK Name = ForeignKeyB_Details ]"}

    I have a txt file which has all the sqltext in it separated by semi colon .Then I try to run a query one by one like this-
                var conn = new SqlCeConnection(ConnectionString);
                conn.Open();
                var cmdArray = Regex.Split(sqlText, ";");
                var cmd = new SqlCeCommand(null, conn);
                foreach (var text in cmdArray)
                    cmd.CommandText = text;
                    if (!text.Equals(string.Empty))
                        cmd.ExecuteNonQuery();
                    else
                        break;
                conn.Close();
    I get the error {"The referenced table must have a primary or candidate key. [ FK Name = ForeignKeyB_Details  ]"}
    here is part of my txt file-
    CREATE TABLE A
           PrimaryId nvarchar(10) NOT NULL REFERENCES C(PrimaryId),
           UserId nvarchar(20) NOT NULL,
           FirstName nvarchar(30) NOT NULL,
           MiddleInitial nvarchar(1) NULL,
           LastName nvarchar(30) NOT NULL,
           MobileNumber nvarchar(20) NULL,
           PhoneNumber nvarchar(10) NOT NULL,
           PhoneExtension nvarchar(6) NULL,
           FaxNumber nvarchar(20) NULL,
           EmailAddress nvarchar(50) NOT NULL,
      CONSTRAINT PrimaryKeyA PRIMARY KEY(PrimaryId, UserId)
    CREATE TABLE B(
       MarketId int NOT NULL references E(MarketId),
       UserId nvarchar(20) NOT NULL,
       UserFirstName nvarchar(30) NOT NULL,
       UserMiddleInitial nvarchar(1) NOT NULL,
       UserLastName nvarchar(30) NOT NULL,
       PhoneNbr nvarchar(10) NOT NULL,
       Extension nvarchar(6) NOT NULL,
       FaxNbr nvarchar(20) NOT NULL,
       Email nvarchar(50) NOT NULL,
       ShortName nvarchar(10) NOT NULL,
    PublicIdFlag nvarchar(6) NOT NULL references D(publicId),
            CONSTRAINT PrimaryKeyB PRIMARY KEY( MarketId, UserId)
    ALTER TABLE B ADD CONSTRAINT ForeignKeyB_Details FOREIGN KEY(UserId, UserFirstName, UserMiddleInitial, UserLastName, PhoneNbr, Extension, FaxNbr, Email) REFERENCES A(UserId, FirstName, MiddleInitial, LastName, PhoneNumber, PhoneExtension, FaxNumber, EmailAddress);

    Hi,
    Foreign key columns are frequently used in join criteria when the data from related tables is combined in queries by matching the column or columns in the FOREIGN KEY constraint of one table with the primary or unique key column or columns in the other table.
    For more information about the foreign key constraint, please refer to this link:
    http://msdn.microsoft.com/en-us/library/ms175464.aspx
    Here is a similar thread for your reference:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/5a71948b-dfb1-46a5-8688-ccab9317e959/error-message-the-referenced-table-must-have-a-primary-or-candidate-key-fk-name-fktblatblb-?forum=sqlce
    Thanks.
    Tracy Cai
    TechNet Community Support

Maybe you are looking for