user670800
user670800

Reputation: 1115

TSQL Insert syntax vs. MySql

I have used this syntax in Mysql :

insert into mytable set firstname='Jo' , set lastname='mvc' ; 

Is that also valid in TSQL ?

Upvotes: 2

Views: 404

Answers (2)

Mitch Wheat
Mitch Wheat

Reputation: 300728

No. For SQL Server you want this syntax for updates:

UPDATE mytable 
SET firstname='Jo', lastname='mvc' 
WHERE someCondition;

(assuming you don't want to update every row, you also need a WHERE clause)

and this for INSERTS:

INSERT INTO mytable (firstname, lastname) 
VALUES ('Jo', 'mvc');  

Upvotes: 4

Mikael Eriksson
Mikael Eriksson

Reputation: 138990

No. Insert statement should look like this

insert into mytable (firstname, lastname)
values ('Jo', 'mvc'); 

If you meant update it would look like this:

update mytable set
  firstname='Jo',
  lastname='mvc' 

With a where clause after if you like.

Upvotes: 3

Related Questions