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)
 Merge Two Fields

Author  Topic 

CoachBarker
Posting Yak Master

170 Posts

Posted - 2009-02-04 : 17:28:52
Say I have a table

TableCustomer

and I have created another table in a Query, so I have

TableCustomer1

now I need to merge a couple of fields from at least one of the tables and they are

cutomer_bill_to and customer_deliver_to have the same customer_number, so what I need is actually the customer, something like :

SELECT cutomer_bill_to AND customer_deliver_to AS customer_combined. Is this possible and have I made it clear what I want?

Thanks for the help
CoachBarker

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-04 : 17:35:53
Please Show us sample data and expected output.
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-02-04 : 17:52:22
Can't you just concatenate both the fields? Like Sodeep said, if you can give sample data and what you expect, it'll be good.
Go to Top of Page

CoachBarker
Posting Yak Master

170 Posts

Posted - 2009-02-04 : 20:04:17
OK I will make it simpler I hope. I have one table, TableCustomer.

customer _number
1,2,3,4,5,6
customer_name
customer_address

the next table is TableCustomerPayments.

payment_number
payment_type
customer_deliver_to(customer_number
1,4,6,
customer_bill_to(customer_number)
1,2,5,6

I need to get

customer_number 1,2,4,5,6

Now in a report for Payments I need information that is based on the Customer. This is based on the customer_number. It doesn't matter if it is for deilver or bill, just the numbers. I also need to check between two dates. Am I better off writing a query where the WHERE part is;

WHERE customer_deliver_to = @customer_number AND customer_bill_to @customer_number AND pickup_date BETWEEN @start_date AND @end_date

or would it be

WHERE customer_deliver_to = @customer_number OR customer_bill_to @customer_number AND pickup_date BETWEEN @start_date AND @end_date

or is there a way to do

WHERE customer_deliver_to AND @customer_number AS @customer_number AND pickup_date BETWEEN @start_date AND @end_date

Make any sense?

Thanks for the help
CoachBarker
Go to Top of Page
   

- Advertisement -