Regarding SELECT INTO in SQL Server
The following throw an error Incorrect syntax near ')'.
SELECT * INTO Sales.MyTable FROM
(SELECT TOP(100) * FROM Sales.Customer)
The following will pass
With tempCust AS
(
SELECT TOP(100) * FROM Sales.Customer
)
SELECT * INTO Sales.MyTable FROM tempCust
What is the rule behind that ?
Can you add an alias
to your subquery
like shown below and then give it a try..
SELECT * INTO Sales.MyTable FROM
(SELECT TOP(100) * FROM Sales.Customer) as abc