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

后端 未结 9 2147
醉梦人生
醉梦人生 2020-12-20 12:15

My stored procedure is trying to write a record in to a database on another Server. The statement is here:

IF @Builds > 0
   BEGIN
        SET @DPU = @Fa         


        
相关标签:
9条回答
  • 2020-12-20 12:55

    Correct four-part table name is server.database.schema.tablename - you have some excess parts there.

    Looks like table name is OPC.WriteRequests? If yes, then you have to use brackets: SQL05.ManufacturingPortal.dbo.[OPC.WriteRequests]

    But maybe you just have some part of name incorrect?

    0 讨论(0)
  • 2020-12-20 12:56

    My (inherited) code was using string.Format and passing the server name, eg

    string.Format("Select * from {0}.AwesomeDB.dbo.EpicTable", WebConfigurationManager.AppSettings["MuhServerName"]);
    

    but in the config, "MuhServerName" was "MyServer.MyDomain.com/MyInstance", so it was loaded as

    Select * from MyServer.MyDomain.com/MyInstance.AwesomeDB.dbo.EpicTable
    

    instead of

    Select * from [MyServer.MyDomain.com/MyInstance].AwesomeDB.dbo.EpicTable
    
    0 讨论(0)
  • 2020-12-20 12:59

    The reason you are receiving the error is because you are not using a valid name. You appear to be referencing two schemata, dbo and OPC.

    The valid syntax is server_name.database_name.schema_name.object_name as referenced on the MSDN article for INSERT.

    Remove the incorrect schema and try again.

    0 讨论(0)
  • 2020-12-20 13:08

    I had the same issue. The problem was due to the following mistake: instead of passing textbox1.text as argument to the query being called from code-behind i passed textbox1.

    Hope it helps

    0 讨论(0)
  • 2020-12-20 13:09

    use with braket "[]" for name and remote database server like this. [87.247.678.80,1666].[danesfe].[admin1].[homefarsi]

    0 讨论(0)
  • 2020-12-20 13:11

    I was using everything correct still the issue persisted. My command was like below

    select * into server.database.schema.table from table2
    

    I resolved it by creating the table in the server first and then used the insert into statement which executed without issues

    Create Table...........
    Insert into server.database.schema.table  select * from table2
    

    Thanks, Sree

    0 讨论(0)
提交回复
热议问题