Showing posts with label Sql. Show all posts
Showing posts with label Sql. Show all posts

Thursday, November 5, 2015

Sql Actual Execution Order

  1. From
  2. On
  3. Join
  4. Where
  5. Group By
  6. with cube
  7. Having
  8. Select
  9. Distinct
  10. Order By
  11. Top

Monday, December 1, 2014

Sql Query Statement Execution Order

FROM
ON
JOIN
WHERE
GROUP BY
WITH CUBE or WITH ROLLUP
HAVING
SELECT
DISTINCT
ORDER BY
TOP

Sunday, October 20, 2013

tsql foreach sample

declare @id int   <-- change your primary key type if necessary
Declare c Cursor For Select Distinct {your primary key} From {your table}
Open c
Fetch next From c into @id
While @@Fetch_Status=0 Begin
 
  --do operations here

   Fetch next From c into @id
End
Close c
Deallocate c