November 30, 2013 at 11:17 pm
Hello
I want to use max() function and I want to read the input of this function from another database(its name is exhibitor). like below :
select @LastDate=MAX([exhibitor.dbo.Maintable.LastUpdate])
but I have error below
Msg 207, Level 16, State 1, Procedure Exec_List, Line 131
Invalid column name 'exhibitor.dbo.Maintable.LastUpdate'.
December 1, 2013 at 3:09 am
Because you referenced a column without a FROM clause.
select @LastDate=MAX([LastUpdate]) FROM exhibitor.dbo.Maintable.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
December 1, 2013 at 3:55 pm
I'd also like to recommend that you avoid 3 part naming in code. Create a synonym for the table in the other database and then stick to 2 part naming. That way, if you even move or rename the database or the table, you won't have to find all of the places it was used in code. All you'll need to do is change the synonym.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply