troubleshooting Question

Excel External Data Connections

Avatar of casper114
casper114Flag for United States of America asked on
Microsoft ExcelMicrosoft SQL Server 2008
4 Comments1 Solution234 ViewsLast Modified:
I currently have an excel spreadsheet used to work up a job profit analysis based upon customers. This was created by somebody else years ago and works fine. I have copied and modified the required tables and SQL queries to duplicate what I want in SQL and to get the data into a table I can just pull from in the spreadsheet. However, once I plug my changes into the sql command text I get unexpected results. Below show the original query, and then the modified query to replace the CustomerID and Address code with the VendorID and vendor Name in my new spreadsheet. However, once this change is input I do not get the same results showing in my spreadsheet as what is returned by the query.

I still get all the fields from the original query, but my 2 changed fields show up as the last 2 returned results instead of closer to the beginning of the results as my Select statement shows they should be located. This has resulted in all automatically returned results being shifted to the left1 to 2 positions (depending on field's place in the select statement) and I can't figure out how to get the fields to populate into my spreadsheet in the same order as they are on the select statement. Can anybody help me figure out what I'm doing wrong?

SELECT JOBANALYSIS.CUSTNMBR, JOBANALYSIS.Service_Call_ID, JOBANALYSIS.ADRSCODE, JOBANALYSIS.DSCVBDT, JOBANALYSIS.DSC_Service_Type, JOBANALYSIS.DSC_BC_VenChgs, JOBANALYSIS.DSC_BC_VenCost, JOBANALYSIS.DSC_BC_VenPrts, JOBANALYSIS.DSC_PV_VenPrts, JOBANALYSIS.EXT_PRICE, JOBANALYSIS.EXT_COST, JOBANALYSIS.FREIGHT_PRICE, JOBANALYSIS.FREIGHT_COST
FROM UCLI1.dbo.JOBANALYSIS JOBANALYSIS

SELECT VENDORID, Service_Call_ID, VENDNAME, DSCVBDT, DSC_Service_Type, DSC_BC_VenChgs, DSC_BC_VenCost, DSC_BC_VenPrts, DSC_PV_VenPrts, EXT_PRICE, EXT_COST, FREIGHT_PRICE, FREIGHT_COST
FROM UCLI1.dbo.JOBANALYSIS_VENDOR
ASKER CERTIFIED SOLUTION
telyni19

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros