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
 General SQL Server Forums
 New to SQL Server Programming
 Run time error 3075

Author  Topic 

JustinC
Starting Member

2 Posts

Posted - 2010-03-05 : 06:49:08
Hi Guys, I am getting Syntax error (missing expression) in query expression for this code.Any ideas why?
I am importing an Access table called "Dividend Postings _GFM" to Excel.

Dim strsql as string

strsql = "SELECT * FROM [Dividend Postings- GFM]where ACCOUNT = ""Martini FX Principal new"" and where Value Date =>""#2/1/2010#"""

Its a Run time 3075 error.

Justin

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2010-03-05 : 08:00:53
t-SQL doesn't use the # sign for dates, just single quotes ('). plus there's a space between Value and Date, if that is the name of the column you need to bracket it.
Try 'SELECT * FROM [Dividend Postings- GFM] where ACCOUNT = ''Martini FX Principal new'' and where [Value Date] => ''2/1/2010'''

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

JustinC
Starting Member

2 Posts

Posted - 2010-03-05 : 09:18:26
Hi Jim, I am still getting Syntax error in query expression
using this code. I am writing it within a VB module within
Excel as I am trying to import from Access. Its related to the date syntax
becuase if I strip that out of the code it works. Any ideas?

strsql = "SELECT * FROM [Dividend Postings- GFM]where ACCOUNT = ""Martini FX Principal new"" and [Value Date] =>'2/1/2010'"

Justin
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2010-03-05 : 13:27:12
Try >= instead of =>. Sorry I missed that before.

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-05 : 13:31:37
better to pass date value as 20100102 else it can error depending on your locale setting

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -