Friday, June 1, 2012

Workaround for SELECT INTO in SQL Azure

If you try to do select insert in SQL Azure like the statement below


INSERT INTO dbo.MyTarget
SELECT ID FROM dbo.MySource



You will get error message:

Statement 'SELECT INTO' is not supported in this version of SQL Server.

There's a quick workaround for that -- use INSERT INTO SELECT statement instead.  The caveat is that you need to create the table beforehand.

CREATE TABLE dbo.MyTarget
(
      ID INT PRIMARY KEY
)

INSERT INTO dbo.MyTarget (ID)
SELECT ID FROM dbo.MySource


No comments:

Post a Comment