Tag Info

New answers tagged

1

If I guessed the missing pieces correctly, this query using a crosstab() function should do the job (and much faster than the original - except for small cardinalities where not much can be gained to begin with): It requires that you install the additional module tablefunc first (once per database. Detailed instructions in this related answer on SO: ...


2

If you are trying to insert into a new table that has already been created, you can say: ;WITH Nbrs ( n ) AS ( SELECT CAST(1 as BIGINT) UNION ALL SELECT 1 + n FROM Nbrs WHERE n < 480000) INSERT dbo.ExistingTable(First,Second,Third,Fourth,Fifth,Sixth) ----^^^^^^ this line SELECT tblOrderRandomNumbers.[1] AS First, ...


1

As @ypercube already explained, the subquery has no reference to columns in the outer query, it can be processed independently. So it is not a "correlated subquery". Some call that a "derived table", or just "subquery". SELECT * FROM orderinfo o , (SELECT * FROM customer c1 WHERE town = 'Bingham') c2 WHERE c2.customer_id = o.customer_id; As to your ...



Top 50 recent answers are included