January 10, 2012 at 4:48 am
Hi All,
i am trying to update some a table from another table in another database but am getting the following error:
Msg 7202, Level 11, State 2, Line 2
Could not find server 'DQMeta1' in sys.servers. Verify that the correct server name was specified. If necessary, execute the stored procedure sp_addlinkedserver to add the server to sys.servers.
this is my code:
begin tran
update [360MetaVerse].dbo.Country
set AreaInContinent = [DQMeta1].[dbo].[_Country].AreaPart,
SafeName = [DQMeta1].[dbo].[_Country].SafeName,
CountryLongName = [DQMeta1].[dbo].[_Country].CountryLongName,
OfficialLanguage = [DQMeta1].[dbo].[_Country].OfficialLanguage
from [DQMeta1].[dbo].[_Country].ISOCountryCodeID
join [DQMeta1].[dbo].[_Country] on [360MetaVerse].dbo.Country.ISOCountryCode = [DQMeta1].[dbo].[_Country].ISOCountryCodeID
Thanks in advance
January 10, 2012 at 4:53 am
your problem is in the FROM part :
[DQMeta1].[dbo].[_Country].ISOCountryCodeID
SQL SErver interprets this as :
[DQMeta1] : Linked server
[dbo] : DbName
...
I guess you want do this instead :
begin tran
update [360MetaVerse].dbo.Country
set AreaInContinent = [DQMeta1].[dbo].[_Country].AreaPart,
SafeName = [DQMeta1].[dbo].[_Country].SafeName,
CountryLongName = [DQMeta1].[dbo].[_Country].CountryLongName,
OfficialLanguage = [DQMeta1].[dbo].[_Country].OfficialLanguage
from [360MetaVerse].dbo.Country
join [DQMeta1].[dbo].[_Country] on [360MetaVerse].dbo.Country.ISOCountryCode = [DQMeta1].[dbo].[_Country].ISOCountryCodeID
January 10, 2012 at 4:57 am
yes that was it, thanks very much
January 10, 2012 at 5:03 am
but can you tell me why the from clause is the table i am updating? i thought it should be where the data is coming from i.e. DQMeta1
January 10, 2012 at 5:11 am
You can write the query as follow as well :
update [360MetaVerse].dbo.Country
set AreaInContinent = [DQMeta1].[dbo].[_Country].AreaPart,
SafeName = [DQMeta1].[dbo].[_Country].SafeName,
CountryLongName = [DQMeta1].[dbo].[_Country].CountryLongName,
OfficialLanguage = [DQMeta1].[dbo].[_Country].OfficialLanguage
from [DQMeta1].[dbo].[_Country]
WHERE [360MetaVerse].dbo.Country.ISOCountryCode = [DQMeta1].[dbo].[_Country].ISOCountryCodeID
Have a look at UPDATE syntax :
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply