Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 16th, 2004, 02:08 PM
mack mack is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 56 mack User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
MS SQL Server SQL syntax vs Access SQL syntax question??

I have the folliwing syntax for a query that works in MS Access, however, when I use it on the
same database converted to MS SQL Server, it does not work. Could some check the syntax and
tell if it is compatible with MS SQL Server.

Thank You

SELECT tblAPCheckbook.strPayee, "AP-Bill" AS Source, [strVendorOrderNumber] & " " & tblAPBill.strReference & " " & tblApBillDetail!memdescription AS NewComment, tblAPCheckbook.dtmDate, tblAPCheckbook.strNum, tblAPBillDetail.strJobID, Sum(tblAPBillDetail.curCost) AS SumOfcurCost, tblAPBillDetail.cntID
FROM tblAPBill INNER JOIN ((tblAPCheckbook INNER JOIN tblAPPayment ON tblAPCheckbook.strNum = tblAPPayment.strPaymentInfo) INNER JOIN (tblAPPaymentDetail INNER JOIN tblAPBillDetail ON tblAPPaymentDetail.strOrderNumber = tblAPBillDetail.strOrderNumber) ON tblAPPayment.strPayableID = tblAPPaymentDetail.strPayableID) ON tblAPBill.strOrderNumber = tblAPBillDetail.strOrderNumber
WHERE (((tblAPCheckbook.ysnPosted)=-1) AND ((tblAPCheckbook.ysnVoid)=0) AND ((tblAPCheckbook.dtmDate) Between [forms]![frmSmReport]![zstxtFromdate] And [forms]![frmSmReport]![zsTxtTodate]) AND ((tblAPPaymentDetail.curPayment)<>0))
GROUP BY tblAPCheckbook.strPayee, "AP-Bill", [strVendorOrderNumber] & " " & tblAPBill.strReference & " " & tblApBillDetail!memdescription, tblAPCheckbook.dtmDate, tblAPCheckbook.strNum, tblAPBillDetail.strJobID, tblAPBillDetail.cntID
HAVING (((tblAPBillDetail.strJobID) Is Not Null));

Reply With Quote
  #2  
Old August 16th, 2004, 02:16 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,760 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 5 h 22 m 16 sec
Reputation Power: 443
You will discover that Access and MS SQL Server are not very compatible at all.

Your query should look along the lines of this, you just need to add the correct values and use your INNER JOINS properly.
Code:
SELECT tblAPCheckbook.strPayee, 
	"AP-Bill" AS Source, 
	[strVendorOrderNumber] + ' ' + tblAPBill.strReference + ' ' + tblApBillDetail.memdescription AS NewComment, 	tblAPCheckbook.dtmDate, 
	tblAPCheckbook.strNum, 
	tblAPBillDetail.strJobID, 
	Sum(tblAPBillDetail.curCost) AS SumOfcurCost, 
	tblAPBillDetail.cntID
FROM tblAPBill 
INNER JOIN tblAPCheckbook ON WHAT?
INNER JOIN tblAPPayment ON (tblAPCheckbook.strNum = tblAPPayment.strPaymentInfo) 
INNER JOIN tblAPPaymentDetail ON WHAT?
INNER JOIN tblAPBillDetail ON (tblAPPaymentDetail.strOrderNumber = tblAPBillDetail.strOrderNumber) 
What is all of this?
ON tblAPPayment.strPayableID = tblAPPaymentDetail.strPayableID) ON tblAPBill.strOrderNumber = tblAPBillDetail.strOrderNumber
WHERE (tblAPCheckbook.ysnPosted = -1)
AND (tblAPCheckbook.ysnVoid = 0)
AND (tblAPCheckbook.dtmDate Between '" & Value1 & "' And '" & Value2 & "')
AND (tblAPPaymentDetail.curPayment <> 0)
GROUP BY tblAPCheckbook.strPayee, 
	"AP-Bill", 
	[strVendorOrderNumber] + ' ' + tblAPBill.strReference + ' ' + tblApBillDetail.memdescription, 
	tblAPCheckbook.dtmDate, 
	tblAPCheckbook.strNum, 
	tblAPBillDetail.strJobID, 
	tblAPBillDetail.cntID
HAVING tblAPBillDetail.strJobID Is Not Null

Reply With Quote
  #3  
Old August 16th, 2004, 02:55 PM
mack mack is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 56 mack User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Smile

Thank You for the response. It turns out the following "(tblAPCheckbook.ysnPosted = -1)"
is based on a "Yes/No" field. Access seemed to have no problem with using -1 but I guess MS SQL Server was not happy.

Thanks Again

Quote:
Originally Posted by Memnoch
You will discover that Access and MS SQL Server are not very compatible at all.

Your query should look along the lines of this, you just need to add the correct values and use your INNER JOINS properly.
Code:
SELECT tblAPCheckbook.strPayee, 
	"AP-Bill" AS Source, 
	[strVendorOrderNumber] + ' ' + tblAPBill.strReference + ' ' + tblApBillDetail.memdescription AS NewComment, 	tblAPCheckbook.dtmDate, 
	tblAPCheckbook.strNum, 
	tblAPBillDetail.strJobID, 
	Sum(tblAPBillDetail.curCost) AS SumOfcurCost, 
	tblAPBillDetail.cntID
FROM tblAPBill 
INNER JOIN tblAPCheckbook ON WHAT?
INNER JOIN tblAPPayment ON (tblAPCheckbook.strNum = tblAPPayment.strPaymentInfo) 
INNER JOIN tblAPPaymentDetail ON WHAT?
INNER JOIN tblAPBillDetail ON (tblAPPaymentDetail.strOrderNumber = tblAPBillDetail.strOrderNumber) 
What is all of this?
ON tblAPPayment.strPayableID = tblAPPaymentDetail.strPayableID) ON tblAPBill.strOrderNumber = tblAPBillDetail.strOrderNumber
WHERE (tblAPCheckbook.ysnPosted = -1)
AND (tblAPCheckbook.ysnVoid = 0)
AND (tblAPCheckbook.dtmDate Between '" & Value1 & "' And '" & Value2 & "')
AND (tblAPPaymentDetail.curPayment <> 0)
GROUP BY tblAPCheckbook.strPayee, 
	"AP-Bill", 
	[strVendorOrderNumber] + ' ' + tblAPBill.strReference + ' ' + tblApBillDetail.memdescription, 
	tblAPCheckbook.dtmDate, 
	tblAPCheckbook.strNum, 
	tblAPBillDetail.strJobID, 
	tblAPBillDetail.cntID
HAVING tblAPBillDetail.strJobID Is Not Null

Reply With Quote
  #4  
Old August 16th, 2004, 04:46 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 21 h 32 m 23 sec
Reputation Power: 180
A bit field won't support a signed value like -1
You can change the column datatype to tinyint, or the value to 1
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > MS SQL Server SQL syntax vs Access SQL syntax question??


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway