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

Configuring Database Mail in MS Sql and sending HTML mail through Job

Hi All, Hope you are doing well. After few weeks, I am going to post a much useful post. Most of the times there are requirements when we need to send automatic notification emails to all or specific email address in the database based on some condition. In such scenario we can take help from… Continue reading Configuring Database Mail in MS Sql and sending HTML mail through Job