This is my code :
SELECT CustomerInfo.NationalID, CustomerInfo.FNama, CustomerInfo.LName, Offers.OfferID, CustomerInfo.MobileNumber, Offers.OfferDescription
FROM CustomerInfo INNER JOIN Offers ON CustomerInfo.OfferID = Offers.OfferID
WHERE (CustomerInfo.UserName = @UserName)
- Moved by Bob BeaucheminMVP Friday, December 28, 2012 11:33 PM Moved to the forum for T-SQL questions (From:.NET Framework inside SQL Server)
I think you wrongly referring a column for that it raise error or Misspelling the table name.
Most of the time we should always be careful when using sub queries in our T-SQL statements and always keep in mind that sub queries can only provide their results to their outer queries and not references to the sub queries' tables. But no sub query exist in your SQL.
Can you show us your table definition?
Ahsan Kabir Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread. http://www.aktechforum.blogspot.com/
The following message would show up if you use a wrong/missing table name or table alias in the query. Can you check that you are using the correct spellings for the alias name "Offers"?Msg 4104, Level 16, State 1, Line 2
The multi-part identifier "Offers.OfferDescription" could not be bound.
Maybe you can use shorter alias names -
SELECT c.NationalID , c.FNama , c.LName , f.OfferID , c.MobileNumber , f.OfferDescription FROM dbo.CustomerInfo AS c INNER JOIN dbo.Offers AS f ON c.OfferID = f.OfferID WHERE (c.UserName = @UserName)
Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers.
Aalam | Blog (http://aalamrangi.wordpress.com)
Some things to check:
- Are you running the query in the correct database context?
- Are the tables in the same database?
- Has the OfferDescription column been added recently, or has the schema changed?
- Do you have a Synonym called Offers?
- Is your database case sensitive, and if so have you checked the case of your SQL against the column name?
- Does the query work if you remove the OfferDescription column?
If the column exists, and it is being referenced correctly in your SQL, then there's no reason why you would get that error.
- Proposed as answer by Naomi NModerator Monday, January 07, 2013 5:50 PM