Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Digit suffix to JOINED (but same) column names

Author  Topic 

curiousharry
Starting Member

2 Posts

Posted - 2008-03-20 : 10:59:52
Using SQL Analyzer or .NET 2.0 programmatically, is there a way to get Transact SQL 2000 to not append a digit at the end of an identifier name when the result set has the same identifier multiple times (from a JOINed SELECT to various tables which have names in common and where I need to get all column names/values in one fell swoop)?

SELECT A.*, B.* from TableA A
INNER JOIN TableB B on (A.Name = B.Name)

The result set will have NAME1 and NAME2, of course (or perhaps it's NAME and NAME1 -- no matter -- I wish to get rid of the numeric suffic).

Thanks much in advance.

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2008-03-20 : 11:06:29
it's just trying to make it unique of course. how about naming them uniquely yourself?

select A.name as someName, B.Name as SomeOtherName
etc...

Em
Go to Top of Page

curiousharry
Starting Member

2 Posts

Posted - 2008-03-20 : 14:11:53
I should have noted that I understood why SQL was doing this. The reason I don't want to the naming is I have perhaps over 100 total columns.. I want joined "identical" column names (A.CustomerID, B.CustomerID, C.CustomerID, etc. to all appear as "CustomerID" -- i.e., without the digit suffixes -- not sure what column property or session option or global option controls this feature in the connection session as I see that the query does not produce the digit-at-end names in SQL Analyzer but does so in C# .NET 2.0 using the usual MS Connection, datset objects, etc.
Go to Top of Page

modi_sanjay
Starting Member

9 Posts

Posted - 2008-03-20 : 14:34:57
I think same as you explain, but when i try to join two table and put A.* , B.* in SELECT, the column name return without numeric suffix

quote:
Originally posted by curiousharry

Using SQL Analyzer or .NET 2.0 programmatically, is there a way to get Transact SQL 2000 to not append a digit at the end of an identifier name when the result set has the same identifier multiple times (from a JOINed SELECT to various tables which have names in common and where I need to get all column names/values in one fell swoop)?

SELECT A.*, B.* from TableA A
INNER JOIN TableB B on (A.Name = B.Name)

The result set will have NAME1 and NAME2, of course (or perhaps it's NAME and NAME1 -- no matter -- I wish to get rid of the numeric suffic).

Thanks much in advance.





Thanks & Regards

Sanjay Modi
Go to Top of Page
   

- Advertisement -