UPDATE ROWS ONTHE TABLE WITHOUT PRIMARY KEY

S

Souris

Is it possible to update a table in SQL server without primary key using
"UPDATE" statement.

I wanted to update a row in the history table which does not have primary
key, because it will have duplicates.

I use link table to set my primary ket in the mdb file, but I got can not
update multi records.

If I take out the primary key then I got need updatable SQL.

Are there any solution for this. Any informauiton is appreciated,
 
D

Douglas J. Steele

I can't imagine a scenario where it's not possible to have a primary key on
a table.

Worst case, add an identity field to the history table and make it the
Primary Key.
 
J

John Smith

Why not add an identity field to the SQL Server table and make that the
primary key?
 
6

'69 Camaro

Hi, Souris.
Is it possible to update a table in SQL server without primary key using
"UPDATE" statement.
No.

I wanted to update a row in the history table which does not have primary
key, because it will have duplicates.

You need to rethink the design of this table. Either it will have a primary
key and no duplicates, or it will have no primary key and allow duplicates
because it is a temporary table. A properly designed relational database has
no duplicate records, except in temporary tables that will usually be deleted
during the current session of transactions.
Are there any solution for this.

Remove the duplicate records from the table so that a primary key can be
assigned to the SQL Server table and updateable Recordsets can be created
from this linked table.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
Beware to those who use munged addresses: known newsgroup E-mail harvesters
for spammers are [email protected] and [email protected]

- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts as "Answers,"
so that all may benefit by filtering on "Answered questions" and quickly
finding the right answers to similar questions. Remember that the first and
best answers are often given to those who have a history of rewarding the
contributors who have taken the time to answer questions correctly.
 
S

Souris

Thanks for message,
My primary key fields are

Account_number varchar(10)
Update_date datetime

If I add a primary key field called 'ID' then can I update liek following

"UPDATE MYTABLE
SET MYFIELD = @MYDATA
WHERE ACCOUNT_NUMBER = @MYACCOUNT_NUMBER AND
UPDATE_DATE = @MYDATETIME"
 
Top