Re: Distrubuted query for inserting
- From: Erland Sommarskog <esquel@xxxxxxxxxxxxx>
- Date: Sat, 3 Mar 2007 14:45:44 +0000 (UTC)
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
.
- Follow-Ups:
- Re: Distrubuted query for inserting
- From: SalamElias
- Re: Distrubuted query for inserting
- Prev by Date: Re: Any good book for T-SQL ??
- Next by Date: Re: Distrubuted query for inserting
- Previous by thread: Re: Any good book for T-SQL ??
- Next by thread: Re: Distrubuted query for inserting
- Index(es):
Relevant Pages
|