Groups | Blog | Home
all groups > sql server msde > september 2005 >

sql server msde : SQL Server 7 with ADO Query Help


Evan Dobkin
9/16/2005 1:49:21 PM
When running the following query against MS SQL Server 7.0:

SELECT

documentitems.manufacturerpartnumber,documentitems.customnumber01,documenthe
aders.customnumber01,documentit

ems.description,documentheaders.projectno FROM DocumentHeaders INNER JOIN
DocumentItems ON

DocumentHeaders.ID = DocumentItems.DocID WHERE (
DocumentHeaders.DocNo='ORLQ1017' AND

DocumentItems.CustomNumber01=2)

It returns 2 records (Which is correct). The problem that I am having is
that I include in the query that

I want the DocumentHeaders.CustomNumber01 field AND the
DocumentItems.CustomerNumber01 field. The field

names in the two different tables are the same. The issue that I have is
that in the query results that

SQL Server returns, it returns two columns with the same name
"CustomerNumber01" and "CustomerNumber01".

SQL Server is not prefixing the field names with the table names like I did
when submitting the query.

This makes it impossible for me the retrieve the separate field values. Is
there a way to get SQL Server

to return the table qualified names of these same named fields?

I am using ADO with Visual Basic 6 to do the query, but I would think in
theory the query should be able to be run in MS Query Analyzer or VB.

Andrea Montanari
9/16/2005 9:56:09 PM
hi Evan,
[quoted text, click to view]

I do not know if I correctly understood your problem, but you can "alias" a
column as you like, like
SELECT [col_name] , [col_name] AS [Alias for 2nd col_name] FROM ...
differentiating the column names in the resultset
--
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtm http://italy.mvps.org
DbaMgr2k ver 0.15.0 - DbaMgr ver 0.60.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
--------- remove DMO to reply

Jorge
9/16/2005 10:56:05 PM
Exactly, you should be use alias for columns with same names.

jorge

[quoted text, click to view]

AddThis Social Bookmark Button