UPDATE Statement without WHERE

J

Jonathan Wood

I want to store some application-wide data in my database. The table that
stores this will store the different data in each field, and there will only
need to be one record.

Since there will only be one record, I haven't bothered to add a key
(primary or otherwise).

This seems to work fine but I'm trying to figure out what my SQL UPDATE
statement would look like. The first time my code runs, I guess I need to
create the single record. But, once created, I don't want to insert
additional records. But without a primary key and some sort of reference to
it, I don't know how to update the single record.

Can anyone help?
 
C

Cor Ligthert[MVP]

Johan,

In what way are you using AdoNet to update, as it is with the regular
DBAdapter Update, then only rows with the rowstate new, changed and deleted
will be done. The Where clause in this will be in my idea only some extra
ballast.

Cor
 
J

Jonathan Wood

So no WHERE is needed? Cool, but can you tell me what this command does if
there are more than one records?

Thanks!
 
P

Patrice

Simply, it will update all rows.

You could still create a primary key with a checked value (of example a byte
pk whose value must be necessarily 0) to express that you can only have a
single record in this table (even if for documentation purpose only).
 
J

Jonathan Wood

Actually, having thought about it some more, updating all the rows makes
sense to me now. That should be suffice for my purposes.

Thanks!
 
W

William Vaughn

I might consider using Extended Properties to store this information as it's
not really relational data--not unless it's used in a JOIN with other
tables..

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
____________________________________________________________________________________________
 
J

Jonathan Wood

It's not used in a JOIN. I don't know what Extended Properties are but it
seems to be working fine now. Perhaps I'll find out what Extended Properties
are at some point.
 
W

William Vaughn

See http://msdn2.microsoft.com/en-us/library/aa496030.aspx

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
____________________________________________________________________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top