Nov
14
2007

Inserting Multiple Rows with MSSQL



Comments available as RSS 2.0

I've been working on adding support for Microsoft SQL Server to iZeit, and there are a few things I've noticed. Firstly, whereas you can addin multiple rows in MySQL or Postgres by using

INSERT INTO tablename (field1,field2,field3) VALUES (r1c1, r1c2, r1c3), (r2c1,r2c2,r2c3)

MSSQL fails and throws an error. Instead, you have to use UNION ALL, which I always thought was more resource intensive.

INSERT INTO tablename (field1,field2,field3) SELECT (r1c1, r1c2, r1c3) UNION ALL SELECT (r2c1,r2c2,r2c3)

The second major annoyance is that MSSQL doesn't like ORDER BY clauses with text fields. Understandably you can't sort a field containing an image, but why can't it sort a text field alphabetically? One thing I still haven't found a workaround for is the LIMIT and OFFSET clauses, which MSSQL doesn't support.

Like this post? Tell someone!
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Google
  • Technorati

Comments

Leave a Comment

Login using OpenID or enter your details below to leave a comment.

OpenID
Anonymous


Comment