iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Database Discussion Forum This is the place to find help resolving those nagging questions you have about implementing and using all kinds of databases. Need help writing a query? Need an opinion on Oracle? Post here!

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-20-2008, 06:14 PM
WebProWorld Member
 
Join Date: Feb 2004
Location: New York
Posts: 82
JSeverson RepRank 0
Default Access to SQL Migration Errors

Hi,
I'm migrating data for a classic ASP site from an MS Access database to a MS SQL database. However, I am now encountering errors with some of the code. I was able to resolve some of the errors by removing the cursor types that the former Web developer was using. I'm still receiving the following error on various pages:

Microsoft OLE DB Provider for SQL Servererror '80040e14'
Incorrect syntax near the keyword 'union'.
/managers/report/original_vendor.asp, line 109


The SQL statement that is executed on line 109 is the following:

select a.accountno,a.schoolid,a.billingperiod,b.date,b.am ount,b.number,b.remark, 0 as adjust,0 as adjamount,c.name from expenses a , expensedtls b,schools c where a.expenseid = b.expenseid and a.schoolid=c.schoolid and a.vendorid=22 and b.date >= '8/1/2008' and b.date <= '8/15/2008' order by c.name,b.date desc,a.expenseid union select '',(select distinct c.schoolid from expenses a , expensedtls b,schools c where a.expenseid = b.expenseid and a.schoolid=c.schoolid and a.vendorid=22 and b.dtlid = adjustments.dtlid),0,date1,0,(select number from expensedtls where dtlid = adjustments.dtlid),remark,adjust,amount as adjamount,(select distinct c.name from expenses a , expensedtls b,schools c where a.expenseid = b.expenseid and a.schoolid=c.schoolid and a.vendorid=22 and b.dtlid = adjustments.dtlid) from adjustments where date1 >= '8/1/2008' and date1 <= '8/15/2008' and dtlid in (select distinct b.dtlid from expenses a , expensedtls b,schools c where a.expenseid = b.expenseid and a.schoolid=c.schoolid and a.vendorid=22) order by name,date

I'm not very familiar with unions so I'm not sure how to fix this error. Or is it an issue with a reserved keyword being used? Could somebody take a look?

Thanks,

Jeff
__________________
Jeff T. Severson
J.T.S. Design, Inc.
Reply With Quote
  #2 (permalink)  
Old 08-20-2008, 07:25 PM
WebProWorld Member
 
Join Date: May 2005
Location: Wisco
Posts: 45
pablowerk RepRank 0
Default Re: Access to SQL Migration Errors

It looks like it's a sql error. It's possible that there is a type near the ~ a.expenseid union select '',( ~ section of your sql statement. If you have access to Enterprise manager, just copy your sql statement into a new querry window. The program will auto format your statement and make it easier to read and figure out where your error is.

hope that helps
Reply With Quote
  #3 (permalink)  
Old 08-21-2008, 05:50 PM
WebProWorld Member
 
Join Date: Feb 2004
Location: New York
Posts: 82
JSeverson RepRank 0
Default Re: Access to SQL Migration Errors

Thanks but the query window wasn't much help. I was actually able to resolve the issue after experimenting a little bit. Access accepted the original statement which contained an Order By clause before the Union. But, MS SQL didn't like that clause. Once I removed it, everything seemed to start working correctly.
__________________
Jeff T. Severson
J.T.S. Design, Inc.
Reply With Quote
  #4 (permalink)  
Old 08-21-2008, 09:04 PM
WebProWorld New Member
 
Join Date: Oct 2005
Posts: 4
apalmer123@msn.com RepRank 0
Default Re: Access to SQL Migration Errors

You can only have one ORDER BY CLAUSE after all the UNION statements, not one in each sub SELECT clause. THe column you are sorting on has to be included in each select statement -- you can use AS to define the name of the selected column so they are all the same.

I also see a weird syntax error in your third line folowing the word union:

union select '',(select distinct

I think the quote and comma are also causing you problems.

HTH, Ann
Reply With Quote
  #5 (permalink)  
Old 08-21-2008, 09:27 PM
WebProWorld Member
 
Join Date: Jan 2006
Location: Sydney Australia
Posts: 60
Christiaan RepRank 1
Default Re: Access to SQL Migration Errors

SQL has some preserved keywords . (Both MS and the PHP variety)
If you use these keywords in your tables and/or fields, you do get errors when accessing the database.
__________________
Chris
There is no failure until you give up.
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Database Discussion Forum

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Site Migration Question relding Webmaster Resources Discussion Forum 6 09-18-2008 10:04 PM
Migration cw1865 Search Engine Optimization Forum 0 01-24-2008 09:08 PM
Error Pages from access errors EmmaGale Web Programming Discussion Forum 10 01-31-2006 11:39 AM
Script Time out errors with Access pbatson Database Discussion Forum 4 04-30-2004 01:27 AM
Forced Hosting Migration-What can you tell me? usabilitymedic Internet Industry 3 04-14-2004 03:45 PM


All times are GMT -4. The time now is 08:25 PM.



Search Engine Optimization by vBSEO 3.3.0