From: lk on
Hi all

I'm using SQL Server 2005 express and the adventureworks sample database to
try and refresh my memory with SQL Server (It's been about 5 years since I
last used it a lot). Can anyone help with a basic question...?

I've written two queries now - one works - one doesn't and I'm not sure why.

The syntax in both is identical (select * from HumanResources.Shift) but one
gives me an "invalid syntax near ." but the other works fine. The only
difference in how I've written them is the one that worked I wrote by right
clkicking on the adventureworks icon on the object explorer. The other one
I just did "File, New, Query with Current Connection".

Must be something fundamental I'm doing wrong. Can anyone help?

Cheers
Rob

From: Erland Sommarskog on
lk (gofyself(a)wrong.address.com) writes:
> I'm using SQL Server 2005 express and the adventureworks sample database
> to try and refresh my memory with SQL Server (It's been about 5 years
> since I last used it a lot). Can anyone help with a basic
> question...?
>
> I've written two queries now - one works - one doesn't and I'm not sure
> why.
>
> The syntax in both is identical (select * from HumanResources.Shift) but
> one gives me an "invalid syntax near ." but the other works fine. The
> only difference in how I've written them is the one that worked I wrote
> by right clkicking on the adventureworks icon on the object explorer.
> The other one I just did "File, New, Query with Current Connection".
>
> Must be something fundamental I'm doing wrong.

Copy and paste both queries in a reply to this post.


--
Erland Sommarskog, SQL Server MVP, esquel(a)sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

From: lk on


"Erland Sommarskog" <esquel(a)sommarskog.se> wrote in message
news:Xns9DA38092825DEYazorman(a)127.0.0.1...

> Copy and paste both queries in a reply to this post.
>


select *
from HumanResources.Shift

From: Erland Sommarskog on
lk (gofyself(a)wrong.address.com) writes:
> "Erland Sommarskog" <esquel(a)sommarskog.se> wrote in message
> news:Xns9DA38092825DEYazorman(a)127.0.0.1...
>
>> Copy and paste both queries in a reply to this post.
>>
>
>
> select *
> from HumanResources.Shift

So this was the query that compiled. At least in runs on my machine.

I think the query with the syntax error is more interesting. Verify
that it gives any error before you post.



--
Erland Sommarskog, SQL Server MVP, esquel(a)sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

From: lk on


"Erland Sommarskog" <esquel(a)sommarskog.se> wrote in message
news:Xns9DA3ACF51D933Yazorman(a)127.0.0.1...
> lk (gofyself(a)wrong.address.com) writes:
>> "Erland Sommarskog" <esquel(a)sommarskog.se> wrote in message
>> news:Xns9DA38092825DEYazorman(a)127.0.0.1...
>>
>>> Copy and paste both queries in a reply to this post.
>>>
>>
>>
>> select *
>> from HumanResources.Shift
>
> So this was the query that compiled. At least in runs on my machine.
>
> I think the query with the syntax error is more interesting. Verify
> that it gives any error before you post.
>
No - you misunderstand.

I have tried the query above twice in two separate windows - one works, one
doesn't.

It's as if one window is connected to the db and one isn't - but I don't
know how to establish the connection.
Therefore I had already verified that it gave me an error (invalid object)
before I posted.