none
Multiple Named Fields RRS feed

  • Question

  •  

    I have a stored procedure which is selected * from more than 1 table. Now 2 of these tables have the same field name (description).

     

    Now throught the C# code when i use

    Code Snippet

    subQuote.desctiption = MyDataReader["description"].ToString();

     

    It grabs the description from the 1st table.

     

    How do i determine which is which?

     

    i have tried the following

    Code Snippet

    subQuote.desctiption = MyDataReader["s.description"].ToString();

     

    but it didnt work.

    Monday, April 7, 2008 5:28 PM

Answers

  • The best way is to avoid the confusion and alter the stored procedure to return unique column names via giving aliases.

    For instance select field ALIAS from table T

    T is an alias to the table called table

    And ALIAS is an alias for the name of the field column.

     

    Monday, April 7, 2008 5:35 PM

All replies

  • The best way is to avoid the confusion and alter the stored procedure to return unique column names via giving aliases.

    For instance select field ALIAS from table T

    T is an alias to the table called table

    And ALIAS is an alias for the name of the field column.

     

    Monday, April 7, 2008 5:35 PM

  • What about something like this:

    Code Snippet

    SELECT DESC_NAME = A.DESCRIPTION,
           DESC_ANOTHER = B.DESCRIPTION

      FROM TABLE A
      JOIN TABLE2 B ON B.ID = A.ID



    Monday, April 7, 2008 5:37 PM