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
 Mention servername in a formula

Author  Topic 

gnaus
Starting Member

41 Posts

Posted - 2011-09-16 : 08:17:54
Dear reader,
I want to insert some records from a table to another existing table. Problem is that de two tables are on different servers.
I don't know how to mention my servername correct.

this is what I have now:
insert EigOpmIndicatieEnClientNrQzorg
select * from ABFKKB01.Intellaacit.AGENKA.gnaus.EigOpmIndicatieEnClientNrQzorg

result: Msg 117, Level 15, State 1, Line 2
The object name 'ABFKKB01.Intellaacit.AGENKA.gnaus.EigOpmIndicatieEnClientNrQzorg' contains more than the maximum number of prefixes. The maximum is 3.

This the table name (it's a view really):
AGENKA\gnaus.EigOpmIndicatieEnClientNrQzorg
(and that's the way the name shows itself in the list with views)

ABFKKB01 =servername
Intellaacit=Database-name

when I omit AGENKA\gnaus
he says:
Msg 208, Level 16, State 1, Line 1
Invalid object name 'ABFPDB01.Intellact.EigOpmIndicatieEnClientNrQzorg'.

does somebody know how to do this?
thank you!






GN

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-09-16 : 08:23:14
Have you setup a linked server?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

gnaus
Starting Member

41 Posts

Posted - 2011-09-16 : 08:27:29
yes I have


GN
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-09-16 : 08:29:00
Then use the four-part naming convention for the remote object:

LinkedServerName.DatabaseName.SchemaName.ObjectName

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-09-16 : 10:19:44
[ABFKKB01].[Intellaacit].[AGENKA/gnaus].EigOpmIndicatieEnClientNrQzorg



Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

gnaus
Starting Member

41 Posts

Posted - 2011-09-16 : 10:28:42
Thank you both. Jimf, you're almost there... ;-), but unfortunately he still can't find the view (but if you notice the error-message: I think the server, database and schema-notation is good now!)

Msg 208, Level 16, State 1, Line 1
Invalid object name 'EigOpmIndicatieEnClientNrQzorg'.




GN
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-09-16 : 10:44:46
Are you trying to insert locally? Seems the table you're inserting into doesn't exist. Or you need to qualify it with the schema name.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-09-16 : 10:55:14
What is this: [AGENKA/gnaus]?

If it's someone's domain account, then the slash is wrong. Should be \ instead.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-09-16 : 11:14:13
It's the INSERT portion that's still broken, not the SELECT.

"Invalid object name" refers to the local server.

If it was the lined server, the error message would be "...lined server does not contain the table..."
Go to Top of Page

gnaus
Starting Member

41 Posts

Posted - 2011-09-16 : 16:53:44
you're totally right I was confused en placed the wrong table at the insert. he works now, but only I have to search a solution for the time stam. If I can't I'll post a message again. thank you (all) very much!

btw, this is it now:
insert [ABFTDB01].[ABR_NAV50SP1_TST_GOOF].dbo.Oefenomgeving$OpmerkingenIndicatie
select * from [ABFPKK01].[Intellaacit].[AGENKA\gnaus].EigOpmIndicatieEnClientNrQzorg

Msg 273, Level 16, State 1, Line 1
Cannot insert an explicit value into a timestamp column. Use INSERT with a column list to exclude the timestamp column, or insert a DEFAULT into the timestamp column.

GN
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-09-16 : 17:57:49
Great. The new error message is pretty self-explanatory.
Go to Top of Page
   

- Advertisement -