

The error I'm getting now is with the loading part.

MYSQL INSERT INTO WITHOUT PRIMARY KEY UPDATE
So I decided to create another table as TableA without IDENTITY(1,1), load the row I want from TableA, update then and so forth.ĭynamic SQL was the option I thought will be suitable. but TableA has IDENTITY(1,1) on the PK, which led me run into errors, saying I'm violating IDENTITY(1,1). So I decided to another table(TableB) with the same structure but exclude ID IDENTITY(1,1), then the take row1 from TableA, put it into TableB, update the two columns of row1 that has to change then put it back to TableA, then it becomes row2, the clone of row1, with two columns changed though. That mean I will have another row(row1) with the same data as row1 except tow columns. I.e TableA has a row(row1) with 6 columns, and I need to clone this row, but changing only two columns. what I decided to was to take a row I need to clone into another table, change the two columns I need to change then put that row back into that table. I need to clone some of the rows in this table, with only two columns changing. I have TableA, it has IDENTITY(1,1) on the PK. THEN st.name + '(' + CONVERT(VARCHAR(4),c.max_length) + ')'ĮXEC sp_executesql = 'INSERT INTO Hosea_tempTable SELECT * FROM ' + +' WHERE (Product_Id = or Product_Id = '''') AND (Fund_Id = or Fund_Id is null)' ĮXEC sp_executeSQL at how I create my temptable, then I want to populate it from the table that I will also be parsing as a parameter, I can't name columns in this instance SET = 'CREATE TABLE dbo.Hosea_tempTable (' When you specify a primary key constraint for a table, the Database Engine enforces data uniqueness by automatically. Because primary key constraints guarantee unique data, they are frequently defined on an identity column. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'.') AND type in (N'U'))ĭECLARE NVARCHAR(MAX), VARCHAR(50), VARCHAR(50), NVARCHAR(MAX), NVARCHAR(MAX), NVARCHAR(MAX) This column, or columns, is called the primary key (PK) of the table and enforces the entity integrity of the table.
