Friday, March 30, 2012

Newbie question on identically named fields in a dataset

This is my first stab at this. I have a simple report that returns a few
columns from a database no sp no expressions just a select statement. There
are two tables that have the same field name and the dataset canâ't seem to
distinguish between them it returns the first field into both columns. When
I run it in Query Analyzer it looks fine. What am I missing here?Query Analyzer seems to be a bit more forgiving about identical names. In
your query, just use Aliases, and you should be ok.
A query like
"Select table1.col1 as Table1Col1, table2.Col1 as Table2Col1 from Table1,
Table2 (...)"
should give you fields named Table1Col1 and Table2Col1. A bit more trouble
to write, but you eliminate possible errors.
Kaisa M. Lindahl
"RYF" <RYF@.discussions.microsoft.com> wrote in message
news:BD3D2857-937A-4602-80AD-C472FB295245@.microsoft.com...
> This is my first stab at this. I have a simple report that returns a few
> columns from a database no sp no expressions just a select statement.
> There
> are two tables that have the same field name and the dataset can't seem to
> distinguish between them it returns the first field into both columns.
> When
> I run it in Query Analyzer it looks fine. What am I missing here?|||THX that did the trick!
"Kaisa M. Lindahl" wrote:
> Query Analyzer seems to be a bit more forgiving about identical names. In
> your query, just use Aliases, and you should be ok.
> A query like
> "Select table1.col1 as Table1Col1, table2.Col1 as Table2Col1 from Table1,
> Table2 (...)"
> should give you fields named Table1Col1 and Table2Col1. A bit more trouble
> to write, but you eliminate possible errors.
> Kaisa M. Lindahl
> "RYF" <RYF@.discussions.microsoft.com> wrote in message
> news:BD3D2857-937A-4602-80AD-C472FB295245@.microsoft.com...
> > This is my first stab at this. I have a simple report that returns a few
> > columns from a database no sp no expressions just a select statement.
> > There
> > are two tables that have the same field name and the dataset can't seem to
> > distinguish between them it returns the first field into both columns.
> > When
> > I run it in Query Analyzer it looks fine. What am I missing here?
>
>

No comments:

Post a Comment