I have a large number of Access tables that I need to periodically bring to SQL using the DTS Wizard in SQL 2000 (via Ent. Man). I am only interested in bring over the data from the MS Access tables as I had a separate script (application drive) that would create the SQL tables.
I'm using sp1, tryng to copy from 2005 db to 2005 db, selecting many tables at once, delete target rows on, identity insert ON.
choosing not to optimize for many tables:
Error: 0xC0202009 at Data Flow Task, Destination - table1 [22]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "The statement has been terminated.".
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Violation of PRIMARY KEY constraint 'PK_table1'. Cannot insert duplicate key in object 'dbo.table1.".
Error: 0xC0202009 at Data Flow Task, Destination 3 - table2 [226]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.
Etc., for each table
Optimizing for many tables:
Error: 0xC0202009 at {AB2253E6-28B4-4D5A-B843-236F8E53E075}, OLE DB Destination [2]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "The statement has been terminated.".
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Violation of PRIMARY KEY constraint 'PK_table1'. Cannot insert duplicate key in object 'dbo.table1.".
Information: 0x402090E0 at {AB2253E6-28B4-4D5A-B843-236F8E53E075}, OLE DB Destination [2]: The final commit for the data insertion has ended.
When I drop and recreate the tables manually and set 'identity insert on' it doesn't bring the identity field over AT ALL.
I like that MS has tried to make it easier to move many tables at once by allowing us to set 'enable identity insert' to everything at once, but it doesn't appear to work. ( I've been puzzling over how it could work, anyway...)
Before sp 1, I had to go into each table by clicking the 'edit' button, and it would bring the correct identity value over, but the tables would no longer have the identity property on that field.
I have also tried 'run as a transaction' to no avail...
I'm trying to transfer data between two 2005 databases using the import/export method. I set the Enable Identity insert to true - edit mappings option - on all the tables but I still get the ID set back to 1. I want to add some live data to an altered database structure, and I'm assuming the import/export tool is the way to do this.
It appears that when you use the import/export wizard from within Microsoft SQL Server Managment Studio, the identity attributes of the table being copied are not transferred. For example, say the source table has a column
[ref] [int] IDENTITY ( 1 , 1 ) NOT NULL,
When the import wizard is done the destination table will have a column named ref, but will not be an identity column. The column definition will be
[ref] [int] NOT NULL,
instead. Is there a way to change this behavior somewhere in the gui? When doing the import, the only options seems to be 'Enable Identity Insert', but checking this does not affect the definition of the column.
Hi there, Having problems exporting data from a database (sql2000 db) to a development db (also sql2000) using SQL 2005 Server Studio and Import/Export wizard (error: Violation of PRIMARY KEY constraint <keynamehere>. Cannot insert duplicate). The destination table has no records in it.
I followed the instructions here:
---------------------------------------------------- Run the following on the 2000 database
Being new to SQL, I started with the basics... using VS2005, it seemed easy enough. Not a single Sql statement was coded by me, but there I was addding, deleting, updating records like a pro. Relations here, bound objects there, The Wizard was my friend. Then I asked him for what I thought was a very simple request: Can I have my @@IDENTITY please? The Wizard grew angry, and hurled error after error at me, null objects were exploding all around me, I tried to reason with him, offering CType's and Try/Catch's but to no avail. I had to seek help for this monster - one after another telling me to SELECT @@IDENTITY, SELECT SCOPE_IDENTITY, but I pleaded with them "I have for the love of god" everywhere possible (if you find yourself wanting to reply now - my answer is YES I tried that), but he would not reviel my identity... Until I took matters into my own hands....
Wizard Says: Private Sub MarketLogFilesBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MarketLogFilesBindingNavigatorSaveItem.Click Me.Validate() Me.MarketLogFilesBindingSource.EndEdit() Me.MarketLogFilesTableAdapter.Update(Me.EveMarketDBDataSet.MarketLogFiles) End Sub
I say: Private Sub MarketLogFilesBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MarketLogFilesBindingNavigatorSaveItem.Click Me.Validate() Me.MarketLogFilesBindingSource.EndEdit() Dim command As New SqlClient.SqlCommand("SELECT @@IDENTITY", Me.MarketLogFilesTableAdapter.Connection) Me.MarketLogFilesTableAdapter.Connection.Open() Me.MarketLogFilesTableAdapter.Update(Me.EveMarketDBDataSet.MarketLogFiles) Dim i As Integer = CType(command.ExecuteScalar(), Integer) Me.MarketLogFilesTableAdapter.Connection.Close() End Sub
Though this code may be totally wrong, it works. I spent many hours trying to find a way that didn't involve me writing my own Update commands, or more to the point, I was sure that such a simple task as retriving the last PK of record had to be in the wizards head somewhere. I am sure there is a simple way to do it, that I have so clearly missed, but for those of you who rely on the wizard, the above at least got me one step closer. It seem's in the auto-gen code, the connection is closed after the update command IF the connection was closed BEFORE the update command was issued.
IF ANYONE CAN FIND ME DOCUMENTATION ON THAT FACT, I WILL GIVE YOU ONE MILLION.... Thanks guys, keep up the great work, I love these forums - inspiration and knowledge -
While I have learned a lot from this thread I am still basically confused about the issues involved.
.I wanted to INSERT a record in a parent table, get the Identity back and use it in a child table. Seems simple.
To my knowledge, mine would be the only process running that would update these tables. I was told that there is no guarantee, because the OLEDB provider could write the second destination row before the first, that the proper parent-child relationship would be generated as expected. It was recommended that I create my own variable in memory to hold the Identity value and use that in my SSIS package.
1. A simple example SSIS .dts example illustrating the approach of using a variable for identity would be helpful.
2. Suppose I actually had two processes updating these tables, running at the same time. Then it seems the "variable" method will also have its problems. Is there a final solution other than locking the tables involved prior to updating them or doing something crazy like using a GUID for the primary key!
3. We have done the type of parent-child inserts I originally described from t-sql for years without any apparent problems. (Maybe we were just lucky.) Is the entire issue simply a t-sql one or does SSIS add a layer of complexity beyond t-sql that needs to be addressed?
I want to insert a new record into a table with an Identity field and return the new Identify field value back to the data stream (for later insertion as a foreign key in another table).
What is the most direct way to do this in SSIS?
TIA,
barkingdog
P.S. Or should I pass the identity value back in a variable and not make it part of the data stream?
I am using the Import wizard to import a SQL2000 database to SQL2005 and noticed 2 problems:
1. all tables and views were selected; the tables were imported correctly but the views were created as tables, ignoring the "Create view" syntax. The SQL generated contains "Create table" syntax instead of "Create View".
2. when a table contained a column with an "identity" property, the data was successfully imported, but the values for the "identity" column were not preserved, instead they were resquenced from 1 with an increment of 1 (the default values for an identity). When I opened the "Edit" (under "Mapping"), "enable identity insert" was not checked.
A further note: I created all tables in the SQL2005 database before running the Import.
I have become frustrated and I am not finding the answers I expect.
Here's the gist, we support both Oracle and SQL for our product and we would like to migrate our Clients who are willing/requesting to go from Oracle to SQL. Seems easy enough.
So, I create a Database in SQL 2005, right click and select "Import Data", Source is Microsoft OLE DB Provider for Oracle and I setup my connection. so far so good.
I create my Destination for SQL Native Client to the Database that I plan on importing into. Still good
Next, I select "Copy data from one or more tables or views". I move on to the next screen and select all of the Objects from a Schema. These are Tables that only relate to our application or in other words, nothing Oracle System wise.
When I get to the end it progresses to about 20% and then throws this error about 300 or so times:
Could not connect source component. Warning 0x80202066: Source - AM_ALERTS [1]: Cannot retrieve the column code page info from the OLE DB provider. If the component supports the "DefaultCodePage" property, the code page from that property will be used. Change the value of the property if the current string code page values are incorrect. If the component does not support the property, the code page from the component's locale ID will be used.
So, I'm thinking "Alright, we can search on this error and I'm sure there's an easy fix." I do some checking and indeed find out that there is a property setting called "AlwaysUseDefaultCodePage" in the OLEDB Data Source Properties. Great! I go back and look at the connection in the Import and .... there's nothing with that property!
Back to the drawing board. I Create a new SSIS package and figure out quickly that the AlwaysUseDefaultCodePage is in there. I can transfter information from the Oracle Source Table to the SQL Server 2005 Destination Table, but it appears to be a one to one thing. Programming this, if I get it to work at all, will take me about 150 hours or so.
This make perfect sense if all you are doing is copying a few columns or maybe one or two objects, but I am talking about 600 + objects with upwards of 2 million rows of data in each!!
This generates 2 questions: 1. If the Import Data Wizard cannot handle this operation on the fly, then why can't the AlwaysUseDefaultCodePage property be shown as part of the connection 2. How do I create and SSIS Package that will copy all of the data from Oracle to SQL Server? The source tables have been created and have the same Schema and Object Names as the Source. I don't want to create a Data Flow Task 600 times.
Hi, I am having problem in bulk update of a sql server table haning identity column from a datatable( has no identity column) using sqlbulkcopy. I tried several approaches, but it does not show any error nor is the table getting updated. But the identity value seems to getting increased every time. thanks. varun
I am setting up a new server with Windows Server 2003 x64 bits and SQL Server 2005 x64 bits. Under 32 bits of Windows we normally use /3GB and enable AWE under SQL Server (both SQL 2000 and SQL 2005) and allocate 6 GB of fixed memory to SQL Server.
Does any one know whether I should do the same thing under the x64 bits platform. I read some articles on the web that it is no longer required to use AWE under SQL 2005 x64 bits??
Hi, I have a SQL Server machine, which has SQL Server 2005 installed in it. I'm able to connect to this server remotely (Remote Desktop Connection) But when I'm trying to connect this SQL Server using SSMS. I'm getting the following error.
TITLE: Connect to Server ------------------------------
I have a create user wizard. On the created user event. I am calling a datasource.insert to insert the email, userid, and opt in to newsletter option into another table. For some reason it is inserting the value twice into the database. I have checked possibilities for why this might be happening. I am pulling my hair out. Any ideas? Andrew
Creating custom Register form That inserts user info in to database via storeprocgetting following errorCompilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30456: 'ValidateInput' is not a member of 'System.Web.UI.WebControls.TextBox'.
Source Error:
Line 3496: Me.__BuildControlTree(Me) Line 3497: Me.AddWrappedFileDependencies(Global.ASP.partfrm_aspx.__fileDependencies) Line 3498: Me.Request.ValidateInput Line 3499: End Sub Line 3500:
<tr> <td align="Left" colspan="2"> <h3> PARTICIPANT INFORMATION: </h3><hr /> Please enter information for the attendee and click 'continue'.</td>
<p> Your account has been successfully created. </p> <asp:Button ID="ContinueButton" runat="server" CommandName="Continue" Text="Continue" />
</asp:WizardStep> </WizardSteps> </asp:Wizard> > CODE-BEHIND 'This event handler fires when the user clicks Finish. We need to insert the new participant record into the database Protected Sub AddParticipant_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles AddParticipantWizard.FinishButtonClick 'Insert the Participant into the database InsertPartDataSource.Insert()
'Send the user back to the homepage Response.Redirect("~/PartReg.aspx") End Sub
I would like to ONLY allow using SQL Server authentication and restrict Windows Authentication. At the moment, i set the security to "SQL server and windows authentication". Now, even though i set the password for "sa", i can ignore the SQL Server authentication and just use Windows authentication to manipulate database objects???
can anybody give some suggestions to restrict windows authentication and allow sql server authentication?.
Hi, I have visual studio 2005 with the sql server express edition that is installed by default when installing vs2005. I am used to work from within vs when I want to create and work with databases for my web sites (I dont have visual manager installed). I would like to enable full text search on a table's column.
Is there an easy way to do that from within vs or is it necessary to install another copy of sql server express with advanced services as well as sql server managment studio express? How can I know if full text search is enabled?
I'm just learning SSIS and I've hit my first bump. I am doing a bulk import from a tab delimited text file to an empty sql table that has a Idendity column defined. How do I tell the bulk insert task to skip that column when inserting from the text file. If I remove the identity column it imports the data fine, but I want to create the indentity column in the table too.
after i have inserted a row into the DB i am trying to get the last identity like this : Dim myCommand2 As New SqlCommand("SELECT @@IDENTITY AS 'Identity'", ) Dim myReader2 As SqlDataReader myReader2 = myCommand2.ExecuteReader() where myConnection2 is the connection objectafter i did this i dont underdsand how do i get the 'Identity' value?i tried myReader2 ('Identity') but no luckany 1 can helpthnaks in advancepeleg
Let me start off by saying I have posted this on: comp.databases.ms-sqlserver
My apologies, try not to do that again.
I have a table that I am trying to insert into with data from another table. Here is that Query:
INSERT INTO item (identifier, name, customlgtxt1, weight,mainprice, customnumber3, customnumber4) Select partno, name, description, weight,price, qtyprice, qty From Import2
This seems to work fine.
My dilemma has to do with an 'id' column in that item table. This is incrementally updated by one..ie Natural Key. I have set it to Identity and used Set @@IDENTITY AS 'id'...worked like a charm. But for reasons that have to do with a front end admin tool used by the home office I can't set this column to have an Indentity property. Screws up the insert done with the admin tool.
This is a item/price database by the way. Name of item, price, description, qty price..etc.
So I've tried to put this trigger on the item table CREATE TRIGGER auto_fill ON [dbo].[item] FOR INSERT, UPDATE AS BEGIN declare @maxc int set @maxc = (select Max(id) from item) set @maxc = @maxc +1 Select 'id' AS '@maxc', notorderable = '0', createdon = getdate(), createdat = getdate(), createdby = 'Steve', modifiedon = getdate(), modifiedat= getdate(), modifiedby = 'Steve'
END
But the Insert Into statement (see above) will not work...giving the error "Cannot insert the value NULL into column 'id', table 'new_Catalog1v1.dbo.item" Which I know...that's why I set it to Identity..but that cannot be.
So the question is how to set an autonumber (or natural key or I'm not sure of the name) that updated from the max(id)table when inserting from another table.
And then...one more.
I have to update a table named UNIQUEIDS with the lastest value of the id column (max(ID))..UNIQUEIDS keeps track of the latest value inserted into the id column for a number of tables. Here is another trigger I put on the item table to update the UNIQUEIDS table.
create trigger upUniqueIds_item on [dbo].[item] for update,Insert, delete as begin Select @@Identity as 'id' from inserted Update uniqueids set id = @@identity Where tablename = 'item' End
But of course this doesn't work if I can't set the columns to IDENTITY.
I hope someone can help and I hope my explanation had made sense. Need to increment the id field using max(id) and update another table with the last imported value of max(id). One occurs during insert..another after the insert..i think?
i have a question: i have a table that has an identity id column called pId and also a column called ParentPid. now my question is that i want to insert the value of pId into the ParentPid when i'm adding a new Property to a table. any idea? thanks