Re: Distrubuted query for inserting



SalamElias (eliassal@xxxxxxxxxxxxx) writes:
I established a linked server, managed to do select (quering the remote
table) in a SP frm the local server . The table has 2 fields, fld 1 is int
(identity), the second is nvarchar(20) as follows

When I try to insert a new line using the following syntax from the
local server, I get errors INSERT INTO
sql2k5.mytable.dbo.MarketingTable1 VALUES ('données depuis Srv1'). The
error I am getting is : "Insert Error: Column name or number of supplied
values does not match table definition."

When deleted the identity column, inserting from local server worked ok.

Any idea of why this is happening? is there restriction on data types when
using distributed queries?

I guess that what the local SQL Server see is a remote table with two
columns. Keep in mind that it does not know that this is an SQL Server
table - it could be Access, Oracle or Active Directory on the other
end of the line.

In any case, it is best practice to always list the columns of the table you
are inserting to. Today the table has two columns, tomorrow it has three,
and then your INSERT till blow up.

--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.



Relevant Pages

  • Re: Connecting to SQL w/ADO
    ... I'm trying to connect to a local server from a local workstation (and ... Internet or MySQL server. ... I would not use the ODBC provider to access SQL Server. ...
    (microsoft.public.vb.database)
  • Re: maximum number of prefixes.
    ... server as a linked server, but this isn't officially supported and ... When you access objects in four-part notation with your own local server, ... everything is done within the local connection. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ...
    (microsoft.public.sqlserver.server)
  • Re: Login without password
    ... "Troubleshooting Orphaned Users" Topic in Books Online ... >How can I delete the login and add it back? ... >>> My SQL Server is version 7.0. ... >>> one old server to a new one, but it is still SQL Server ...
    (microsoft.public.sqlserver.security)
  • Re: Help a newb (issue with excel, ms access and SQL Server)
    ... I can't figure it out how to do this in SQL server. ... I was using the following to create an excel file based on the select ... I believe there are some examples in Books Online. ...
    (comp.databases.ms-sqlserver)
  • Re: beware: SQL2005 management studio not 2000 compatible
    ... SQL2005 management told me that some feature was not supported on SQL 2000 ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (microsoft.public.sqlserver.tools)