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
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?
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
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.
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
use with braket "[]" for name and remote database server like this. [87.247.678.80,1666].[danesfe].[admin1].[homefarsi]
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