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.
| 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 stringstrsql = "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'''JimEveryday I learn something that somebody else already knew |
 |
|
|
JustinC
Starting Member
2 Posts |
Posted - 2010-03-05 : 09:18:26
|
| Hi Jim, I am still getting Syntax error in query expressionusing this code. I am writing it within a VB module withinExcel 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 |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2010-03-05 : 13:27:12
|
| Try >= instead of =>. Sorry I missed that before.JimEveryday I learn something that somebody else already knew |
 |
|
|
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 MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|