October 7, 2009 at 3:59 pm
Is there any known problem with inserting a row via distributed query to table on another server where the table in question has an identity column?
Here is the structure of the table I'm trying to write to:
CREATE TABLE dbo.dba_debug
(
dbg_identity int IDENTITY,
dbg_step int NULL,
dbg_desc varchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
dbg_datetime datetime NULL
)
The query I'm using:
INSERT INTO SERVER2.database.dbo.table
SELECT1 as dbg_step,
'Text String' as dbg_desc,
GETDATE() as dbg_datetime
...generates the following error.
Msg 213, Level 16, State 1, Line 2
Column name or number of supplied values does not match table definition.
If I run the query above on SERVER2 itself it runs fine and the identity is populated.
Thanx...
October 7, 2009 at 6:04 pm
Try to at least do this in all your insert statements. Relying on order can get you into trouble when schema changes down the road.
INSERT INTO SERVER2.database.dbo.table (dbg_step, dbg_desc, dbg_datetime)
SELECT 1 as dbg_step,
'Text String' as dbg_desc,
GETDATE() as dbg_datetime
-Chuck
@SQLGuyChuck
October 8, 2009 at 8:55 am
Thanks much. No idea why I didn't think of that.
Plaid...
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply