GO, OFFSET and FETCH clauses & PAGING in MS SQL

GO: GO { integer_constant} GO will execute the related sql commands n times. INSERT INTO mytable DEFAULT VALUES GO 10 The above will insert 10 rows into mytable. OFFSET: OFFSET { integer_constant | offset_row_count_expression } { ROW | ROWS } Specifies the number of rows to skip, before starting to return rows from the query… Continue reading GO, OFFSET and FETCH clauses & PAGING in MS SQL

RDBMS Keys

I’ll take example of an Employee table: Employee ( Employee ID, FullName, SSN, DeptID ) 1. Candidate Key: are individual columns in a table that qualifies for uniqueness of all the rows. Here in Employee table EmployeeID & SSN are Candidate keys. 2. Primary Key: is the columns you choose to maintain uniqueness in a… Continue reading RDBMS Keys

Cursor In MS Sql – Example

declare @UserId int declare @TrnDate datetime create table #TempAttendance( UserId  int, TrnDate datetime) –select max(UserID) as UserID, cast(TrnDate as date) as TrnDate from UserAttendanceInOut –group by cast(TrnDate as date) insert into #TempAttendance select max(UserID) as UserID, cast(TrnDate as date) as TrnDate from UserAttendanceInOut group by cast(TrnDate as date) –select * from #TempAttendance — Cursor Declaration… Continue reading Cursor In MS Sql – Example