Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 [Resolved] Problem inserting records

Author  Topic 

snufse
Constraint Violating Yak Guru

469 Posts

Posted - 2009-02-04 : 08:34:43
I have problems inserting records into a Sequel Server 2005 table.

Here is the code:

insert into ZyTax.dbo.xtable(report_state, report_year, report_month, company) 
exec('Select ztadds, ztyear, zt#mt, ztco from vgiprddta.f55125x') at AS400SRV_MSDASQL


I'm using a linked server to db2/400. There are 25 records in the source file and layout is the same for both source and target tables. The query never completes. Can anyone suggest what I should look at? Thank you.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-02-04 : 08:42:16
I suggest you open SQL Profiler to determine if the locking occurs on SQL Server side or AS400 side.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-04 : 08:49:27
whay are you using dynamic sql here?
Go to Top of Page

snufse
Constraint Violating Yak Guru

469 Posts

Posted - 2009-02-04 : 09:06:51
What is the alternative of not using dynamic slq?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-04 : 09:12:12
[code]
insert into ZyTax.dbo.xtable(report_state, report_year, report_month, company)
Select ztadds, ztyear, zt#mt, ztco from AS400SRV_MSDASQL.yourdbhere.vgiprddta.f55125x
[/code]
Go to Top of Page

snufse
Constraint Violating Yak Guru

469 Posts

Posted - 2009-02-04 : 09:40:48
This is very confusing:

Had to change the provider:

AS400SRV_MSDASQL.Vgsys400.vgiprddta.f55125x - does not work

AS400SRV_IBMDASQL.Vgsys400.vgiprddta.f55125x - works

I am all set, thank you very much
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-04 : 09:42:57
welcome
Go to Top of Page
   

- Advertisement -