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.
Author |
Topic |
arv_rehal1381
Starting Member
4 Posts |
Posted - 2013-09-28 : 09:13:22
|
I was trying to copy data from two tables to one table in same database by using Import Data functionality under TASK. I am using this viewSELECT dbo.AnnotationBase.ModifiedBy AS PrincipalId, dbo.AnnotationBase.AnnotationId AS ObjectId, 5 AS ObjectTypeCode, 8 AS PrincipalTypeCode, 0 AS AccessRightsMask, dbo.AnnotationBase.ModifiedOn AS ChangedOn, NEWID() AS PrincipalObjectAccessId, 135069719 AS InheritedAccessRightsMaskFROM dbo.AnnotationBase LEFT OUTER JOIN dbo.SystemUserBase ON dbo.AnnotationBase.ModifiedBy = dbo.SystemUserBase.SystemUserIdBut when I am running this it is giving me this errorError 0xc0202009: Data Flow Task 1: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.An OLE DB record is available. Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80004005 Description: "Unspecified error". (SQL Server Import and Export Wizard)Thanks |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2013-09-28 : 15:09:29
|
Do this instead:SELECT dbo.AnnotationBase.ModifiedBy AS PrincipalId, dbo.AnnotationBase.AnnotationId AS ObjectId, 5 AS ObjectTypeCode, 8 AS PrincipalTypeCode, 0 AS AccessRightsMask,dbo.AnnotationBase.ModifiedOn AS ChangedOn, NEWID() AS PrincipalObjectAccessId, 135069719 AS InheritedAccessRightsMaskINTO NewTableNameFROM dbo.AnnotationBase LEFT OUTER JOIN dbo.SystemUserBase ON dbo.AnnotationBase.ModifiedBy = dbo.SystemUserBase.SystemUserIdTara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
arv_rehal1381
Starting Member
4 Posts |
Posted - 2013-09-28 : 15:21:19
|
Hi,Thanks for your reply, Yes, your query worked it can create new table with same column and data but what is the problem in using existing table.Thanks |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2013-09-30 : 11:04:27
|
If you want to copy data to an existing table, then use this instead:INSERT INTO ExistingTableSELECT dbo.AnnotationBase.ModifiedBy AS PrincipalId, dbo.AnnotationBase.AnnotationId AS ObjectId, 5 AS ObjectTypeCode, 8 AS PrincipalTypeCode, 0 AS AccessRightsMask,dbo.AnnotationBase.ModifiedOn AS ChangedOn, NEWID() AS PrincipalObjectAccessId, 135069719 AS InheritedAccessRightsMaskFROM dbo.AnnotationBase LEFT OUTER JOIN dbo.SystemUserBase ON dbo.AnnotationBase.ModifiedBy = dbo.SystemUserBase.SystemUserIdTara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
|
|
|
|
|