
Search In
In this post we will see how to use JOIN for deleting data from SQl server table. Let us first create tables which we will use for understanding the deletion process using JOINS.
-- Create table1
CREATE TABLE #Table1 (Col1 INT, Col2 VARCHAR(50))
INS
Sometimes we may be required to get the get last N records of a table in SQL server based on ordering on a specific column . In this post we will create a query to get the result. First let us create a table which we will use in our query.
CREATE T
1. SQL WHERE Clause:-
SQL WHERE Clause is one of the most useful feature of the SQL query as it is used to specify a condition while fetching the data from single table or joining with multiple tables,it also allows you to select specific rows
i
CTE
CTE stands for Common Table expressions. It was introduced with SQL Server 2005. It is a temporary result set and typically it may be a result of complex sub-query.CTE improves readability and ease in maintenance of complex queries and sub-que
A Cursor allow us to retrieve data from a result set in single means row by row. Cursor are required when we need to update records in a database table one row at a time.
Types of Cursors
Static Cursors
A static cursor populates the result
SQL Server 2012 Programmability Enhancements
SQL Server 2012 supports a great programmability enhancements and functions :
T-SQL THROW Statement
Now SQL Server 2012 has improved error handling by introducing throw statement for throwing excep
Sometimes during application development we need to do case sensitive search. Let us see how we can do the same in SQL Server.
For illustration purpose we will use a table called Technology which has a column named Platform.Now let us say column pla
CTE:Common Table Expressions
1)CTE's replace subqueries i.e they are result of complex queries so can be defined as temporary resultset.
2)CTE's are mainly used for recursive programming.
3)The lifetime of CTE's is the individual query it live in
Databases whose data is not required to be changed should be considered to be set as READ ONLY.Databases can be set to READ ONLY mode and back using T-SQL and SSMS.
Following are the scripts that can be used to set database read only and back:
--
Following are some useful SQL Server Date functions to find specific dates.
1) Today
SELECT GETDATE() 'Today'
2) Yesterday
SELECT DATEADD(d,-1,GETDATE()) 'Yesterday'
3) First Day of Current Week
SELECT DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0) '
