SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


The object name ... contains more than the maximum number of prefixes. The maximum is 2.


The object name ... contains more than the maximum number of prefixes. The maximum is 2.

Author
Message
jsblakley
jsblakley
SSC Rookie
SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)

Group: General Forum Members
Points: 25 Visits: 1

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





rfrancisco
rfrancisco
Valued Member
Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)

Group: General Forum Members
Points: 56 Visits: 13
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>.



http://www.sql-server-helper.com
Erik Easton
Erik Easton
Grasshopper
Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)

Group: General Forum Members
Points: 15 Visits: 3

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.


Peter Byrne
Peter Byrne
Grasshopper
Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)

Group: General Forum Members
Points: 11 Visits: 1
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.
Dan Fell
Dan Fell
Grasshopper
Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)

Group: General Forum Members
Points: 15 Visits: 16
Cheers Erik, that's got me up and running again.

Like you said, it's beautiful when you know the answer!
Tim Mitchell
Tim Mitchell
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1781 Visits: 2988
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


Ed Hammar
Ed Hammar
SSC-Enthusiastic
SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)SSC-Enthusiastic (106 reputation)

Group: General Forum Members
Points: 106 Visits: 5

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.


Chris Harrod
Chris Harrod
SSC-Enthusiastic
SSC-Enthusiastic (138 reputation)SSC-Enthusiastic (138 reputation)SSC-Enthusiastic (138 reputation)SSC-Enthusiastic (138 reputation)SSC-Enthusiastic (138 reputation)SSC-Enthusiastic (138 reputation)SSC-Enthusiastic (138 reputation)SSC-Enthusiastic (138 reputation)

Group: General Forum Members
Points: 138 Visits: 233
Thanks Tim.

Insert into rather than a Select into works a treat accross a linked server
lessingh
lessingh
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 Visits: 22
How did you get the select into query to work
MarkusB
MarkusB
SSCertifiable
SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)

Group: General Forum Members
Points: 5783 Visits: 4208
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.

Markus Bohse
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search