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
 Convert Access Query

Author  Topic 

sirmilt
Starting Member

49 Posts

Posted - 2010-11-02 : 12:49:48
This query works perfectly in Access 2000,

SELECT tblBooks.*, tblOnLoan.*
FROM tblBooks LEFT JOIN tblOnLoan ON [tblBooks].[ID]=[tblOnLoan].[CollectionID]
WHERE [tblBooks].[ID]=[@ID];

I am trying to convert from Access to SQL Server 2008 EXpress R2 and when I try to use the same query in my Visual Basic 2008 program I get the error "Invalid column name '@ID'."

There may be situations where there is no record in the tblOnLoan but there will always be a record in the table tblBooks.

Milt

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-11-02 : 13:00:25
quote:
Originally posted by sirmilt

This query works perfectly in Access 2000,

SELECT tblBooks.*, tblOnLoan.*
FROM tblBooks LEFT JOIN tblOnLoan ON [tblBooks].[ID]=[tblOnLoan].[CollectionID]
WHERE [tblBooks].[ID]=@ID;

I am trying to convert from Access to SQL Server 2008 EXpress R2 and when I try to use the same query in my Visual Basic 2008 program I get the error "Invalid column name '@ID'."

There may be situations where there is no record in the tblOnLoan but there will always be a record in the table tblBooks.

Milt




No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-11-02 : 13:57:45
Get rid of the select *

list the columns you want



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx





Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-11-03 : 04:44:44
You need to declare and assign a value to the variable @ID

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -