I get
SELECT INTO statement is not supported in this version of SQL Server in SQL Server
for the request below inside the stored procedure
DECLARE @sql NVARCHAR(MAX) ,@sqlSelect NVARCHAR(MAX) = '' ,@sqlFrom NVARCHAR(MAX) = '' ,@sqlTempTable NVARCHAR(MAX) = '#itemSearch' ,@sqlInto NVARCHAR(MAX) = '' ,@params NVARCHAR(MAX) SET @sqlSelect ='SELECT ,IT.ITEMNR ,IT.USERNR ,IT.ShopNR ,IT.ITEMID' SET @sqlFrom =' FROM dbo.ITEM AS IT' SET @sqlInto = ' INTO ' + @sqlTempTable + ' '; IF (@cityId > 0) BEGIN SET @sqlFrom = @sqlFrom + ' INNER JOIN dbo.CITY AS CI2 ON CI2.CITYID = @cityId' SET @sqlSelect = @sqlSelect + 'CI2.LATITUDE AS CITYLATITUDE ,CI2.LONGITUDE AS CITYLONGITUDE' END SELECT @params =N'@cityId int ' SET @sql = @sqlSelect +@sqlInto +@sqlFrom EXEC sp_executesql @sql,@params
I have about 50,000 records, so I decided to use the Temp Table. But surprised to see this error.
How can I achieve the same in SQL Azure?
Edit: Reading this blog is http://blogs.msdn.com/b/sqlazure/archive/2010/05/04/10007212.aspx , asking us to CREATE a table inside a stored procedure to store data instead of a Temp table. Is it safe with concurrency? Will performance hit?
Adding some points taken from http://blog.sqlauthority.com/2011/05/28/sql-server-a-quick-notes-on-sql-azure/
- Each table must have a clustered index. Tables without a clustered index are not supported.
- Each connection can use one database. Multiple databases in a single transaction are not supported.
- 'USE DATABASE cannot be used in Azure.
- Global Temp tables (or Temp Objects) are not supported.
- Since there is no concept of connecting to cross databases, a linked server is not a concept in Azure at this time.
- SQL Azure is a common environment, and because of this, there is no concept of Windows login.
- Always discard TempDB objects after they are needed, as they create pressure on TempDB.
- When inserting buck, use the batchsize parameter to limit the number of rows inserted. This will limit the use of transaction log space.
- Avoid unnecessarily using grouping or blocking ORDER operations, as they result in high memory usage.
sql sql-server azure-sql-database
Murali murugesan
source share