UPDATE Statement

Jerkstore

New Member
UPDATE <table>
SET(row1, row2, row3)
VALUES(value1, value2, value3)
WHERE <condition> = <instance>;

ex.
UPDATE customers
SET(firstname, lastname)
VALUES("Joe", "Shmoe")
WHERE id = 1;
 

SFR

Truth fears no questions
Jerkstore said:
UPDATE <table>
SET(row1, row2, row3)
VALUES(value1, value2, value3)
WHERE <condition> = <instance>;

ex.
UPDATE customers
SET(firstname, lastname)
VALUES("Joe", "Shmoe")
WHERE id = 1;

..That is SQL+. For MS Sql Server you do not need the semicolon and make sure to use 'single quotes'....
 

Jerkstore

New Member
what are you updating?
what type of front end code and back end database?

you're right SFR, there are more ways also, client/server dependant
 

SFR

Truth fears no questions
houssam_ballout said:
I am using Access with VB, so does that works?
thanks

wait a second...

insert into customers (firstname, lastname) values ('Joe', 'Shmoe') where id = 1

update customers set firstname = 'Joe', lastname = 'Shmoe' where id = 1


...that is correct.
 

Jerkstore

New Member
yeah the last one SFR posted should work, or make a stored procedure:

CREATE PROCEDURE p_UpdateCustomer
(
@firstname varchar(25),
@lastname varchar(25)
)
AS
UPDATE Customers
SET
firstname = @firstname,
lastname = @lastname
WHERE id =1


(I'm pretty sure thats the syntax...to be used in MSSQL query analyser)
 

SFR

Truth fears no questions
the only problem with the sp is that he is using Access and VB which are both of SQL Server syntax
you need a declare, begin and end... But that is neither here nor there... Access does not have stored procedures... and I believe macros are different.
 

Jerkstore

New Member
Access doesn't allow stored procedures!?
Ghetto...been so long since I've used access for anything, lol

Once you go stored procedures, you never go back :)
 

SFR

Truth fears no questions
houssam_ballout said:
is there triggers and stored proc. in access??

No there is not... that is why jerkstore and I are continuing this conversation

EDIT:
you could use some VBA and create a form that will act as a trigger when code is changed.... (dont mean to open a Pandora's box.. so do some research the information is out there!)...

 
Last edited:
Top