April 1, 2005 at 3:12 pm
I am attempting to call a stored procedure from a separate sql server box and I receive the following message...
The object name 'prod1.tolim.dbo.' contains more than the maximum number of prefixes. The maximum is 2.
Here is the statement in my stored proc....
exec PROD1.ToLIM.dbo.ToLIM_ExtractIndex @vDB, @vDBTable, @vLIMSymbol = 'CIN.CINERGY_LOAD', @vLIMColumn = 'CIN.ESAL_LESS_ORPHAN', @vTimeUnits = 'HOURLY_COLUMNS', @dDateStart = '1999-01-01', @dDateEnd = '2005-03-03'
I am executing from my dev server to my prod server and the prod server is a linked server.
Any help would be appreciated.
Jeff
April 1, 2005 at 11:21 pm
One of the possible reasons for getting this error is when trying to create a table and the statement is using the 4-part table name instead of just the 3-part name. If it does, remove the server name as part of the create table statement and just use <DatabaseName>.<Owner>.<TableName>.
November 15, 2006 at 3:51 pm
The error I got was very similar. I was trying to do the following update and "push" the data across to a linked server:
update ServerName.AAD.dbo.t_employee
set ServerName.AAD.dbo.t_employee.work_shift = wa.work_shift
from t_employee wa
where ServerName.AAD.dbo.t_employee.id = wa.id
and wa.id = '105'
I was getting the following:
Server: Msg 117, Level 15, State 2, Line 4
The number name 'ServerName.AAD.dbo.t_employee' contains more than the maximum number of prefixes. The maximum is 3.
I couldn't find any other threads with my answer. Maybe I'm alone on this but it took me hours to find this solution, so I thought I'd post it here in hopes it helps out the next person searching on this.
It's a simple, but not obvious, answer. Put the table you are updating in the FROM clause with an alias and update the alias, as follows:
update la
set la.work_shift = wa.work_shift
from ServerName.AAD.dbo.t_employee la, t_employee wa
where la.id = wa.id
and wa.id = '105'
Beautiful, ins't it? That is when you have the answer.
December 13, 2006 at 2:05 pm
This seriously saved my ass. This is the only way to use an UPDATE with linked servers when you want to update only one column.
Thank you, thank you, thank you.
March 14, 2007 at 9:44 am
Cheers Erik, that's got me up and running again.
Like you said, it's beautiful when you know the answer!
May 25, 2007 at 8:40 am
I ran into the same error, but I was trying to do a SELECT...INTO in a linked server. I had to script the table on the target DB, then run an INSERT...SELECT. A pain, but it got the job done.
Tim Mitchell, Microsoft Data Platform MVP
Data Warehouse and ETL Consultant
TimMitchell.net | @Tim_Mitchell | Tyleris.com
ETL Best Practices
May 25, 2007 at 2:54 pm
That query should work fine, the only guess I have is the way you are calling it. Try the following:
exec PROD1.ToLIM.dbo.ToLIM_ExtractIndex @vDB, @vDBTable, 'CIN.CINERGY_LOAD', 'CIN.ESAL_LESS_ORPHAN', 'HOURLY_COLUMNS', '1999-01-01', '2005-03-03'
SQL Server is pretty picky about calls made to stored procedures when parameters are named so I'm guessing that's the issue.
March 25, 2008 at 7:16 pm
Thanks Tim.
Insert into rather than a Select into works a treat accross a linked server
March 31, 2008 at 5:23 am
How did you get the select into query to work
March 31, 2008 at 5:43 am
Could this be a permission problem ?
For INSERT INTO you only need datawriter permissions, while for a SELECT INTO you need at least CREATE TABLE permissions.
[font="Verdana"]Markus Bohse[/font]
July 10, 2008 at 6:51 pm
Having the same problem, but I need to use BULK INSERT. I will be inserting > 150K records and I don't think anything else is as good as Bulking.
BULK INSERT MYLINKEDSRV.myDatabase.dbo.BCPTable
FROM 'C:\list.csv'
WITH (FORMATFILE = 'C:\format_file.xml')
Milford
September 9, 2008 at 7:26 am
Can I alter a table using Linked server?
February 15, 2009 at 2:10 am
Hi, We used to backup few SQL Server 2005 tables into MS Access file. The access file is accessed by using linked server.
sp_addlinkedserver 'AccessBackup', 'Access 97', 'Microsoft.Jet.OLEDB.4.0', 'D:\Shaju\AccessBackup\InputDB.mdb'
sp_addlinkedsrvlogin 'AccessBackup', false, 'sa', 'Admin', NULL
1) SELECT * FROM [AccessBackup]...[MailingList]
Works fine.
2) SELECT *
INTO [AccessBackup]...[Cities]
FROM [dbo].[tblCities]
Iam trying to back up tblCities to access db. The error i get is
The object name 'AccessBackup...Cities' contains more than the maximum number of prefixes. The maximum is 2.
3) INSERT INTO [AccessBackup]...[Cities]
SELECT * FROM [dbo].[tblCities]
The error i get is
The OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "AccessBackup" does not contain the table "Cities". The table either does not exist or the current user does not have permissions on that table.'
How to use select into a linked server
February 15, 2009 at 2:11 am
Hi, We used to backup few SQL Server 2005 tables into MS Access file. The access file is accessed by using linked server.
sp_addlinkedserver 'AccessBackup', 'Access 97', 'Microsoft.Jet.OLEDB.4.0', 'D:\Shaju\AccessBackup\InputDB.mdb'
sp_addlinkedsrvlogin 'AccessBackup', false, 'sa', 'Admin', NULL
1) SELECT * FROM [AccessBackup]...[MailingList]
Works fine.
2) SELECT *
INTO [AccessBackup]...[Cities]
FROM [dbo].[tblCities]
Iam trying to back up tblCities to access db. The error i get is
The object name 'AccessBackup...Cities' contains more than the maximum number of prefixes. The maximum is 2.
3) INSERT INTO [AccessBackup]...[Cities]
SELECT * FROM [dbo].[tblCities]
The error i get is
The OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "AccessBackup" does not contain the table "Cities". The table either does not exist or the current user does not have permissions on that table.'
How to use select into a linked server
February 25, 2009 at 1:54 am
i got this error when i tried to call a function from a linked server in my select query. here's what caused my problem:
set @myquery =
'select
PurchClaims =' + @database + '.dbo.fn_PurchClaimAmount(bb.Pinvno,b.Blockno),
from #sp_agingAgingCopy_Blocks as bb
INNER JOIN ' + @database + '.dbo.Blocks b on bb.blockno = b.blockno
so in other words it seems that while you can select from a linked server table, you cannot call functions from that linked server within the select.
in this case @database was "[192.168.0.2\dev].bs_bkup_sa_global_jan"
the alternative i had to use to still get the data was to add another column, "Purchclaims" to my #sp_agingAgingCopy_Blocks table, then i had to create a cursor or query before this select to insert those values.
Viewing 15 posts - 1 through 15 (of 22 total)
You must be logged in to reply to this topic. Login to reply