SQL samples and examples



You can make money from this site by posting original and quality articles that comply with Google AdSense policies.. Also, we offer several other reward programs including monthly profit sharing, cash rewards per post, contests & prizes etc to contributing members.

Submit Your Article

Articles

Introduction to SqlBulkCopy

I have demonstrated simple example of SqlBulkCopy and how it can be used. Data transfer will be easy with the help of SqlBulkCopy. Everytime it initializes a new instance of the SqlBulkCopy. Manual data transfer can be automated using this code.

T-sql CTE in SQL Server

Common Table Expression in t-sql is introduced in SQL Server 2005. CTE is a temporary result set used as a derived table and also that can be declared once and reference anywhere in a query. CTE only exist only in the scope of current query. We can also use CTE recursively in a query.

Pivot tables in sqlserver 2008

In this article we are going to see what is a PIVOT table. What are the advantages of using a pivot table. A Pivot Table is a Table which can count and total the data stored in a column and use it to create a second table which displays the summarized data. The PIVOT keyword in sqlserver displays the values of a specified column as column name.

To Find No.of Days in a month and enter working days into table

Here I am Creating a stored procedure for Finding No.of Days in a month. You can pass the date from your front-end.I am setting a Date manually.Here adding the date of February 2013.Just check how many days in 2012 February.In front-end you can use a calender control and select the date and pass it. And Suppose you have a table as Working days.How to enter the days of a month into the table. Just Try

Cursor in SQL Server

This article summarise the use of cursor in T-SQL Statments. I have explained the use of single Cursor and Nester Cursor (Nested Level is 2). While Loop can also be used for this purpose. I have explained the use of While loop in my previous article Nested Looping in SQL Server.

Nested Looping in SQL Server

This article summaries the use of While Loop in SQL Server. I have explained the use of Single While Loop and Nested While Loop (Nested Level is 2). The cursor also would solve this purpose but it will result in performance issue. when compared to Cursor the While Loop usage is simple and easiest one.

Sql server 2005 query to list of procedures using particular table

Using SQL, can I get list of all stored procedures that are using a particular table say Bank table This is mainly used at the time when there is alteration in the structure of the bank table simply executing this would give you list of all sps, views, etc which depend on that particular table i use this all the time as i work with a db which has over 400 tables

How to load/migrate data from .CSV file to mySQL table?

Data migration means migrating data from one place to another place. Generally, mySQL queries are used to retrive ,add , update , delete data. We have used mySQL query for migration purpose. I hope this will be useful to all.

Date validation in query

Get record between specific date range. means retrieve the all record on the basis of date range. my store procedure help you solve this date range problem. Find below store procedure and try it. i hope it will helpful to you.

Sysstat in SQL Query

sysstat used in SQL server to map the type of the Objects like stored procedures, triggers etc. These are mainly used to check the availability or is created already. If it is created then we can modify or delete those things.

Create Update Procedure Automatically in MS SQL

Here I am going to explain you how to create Update Procedure Automatically without spending much time. You just need to pass the required parameter to this procedure, rest of the things will be taken care by this simple procedure.

Table Valued Parameters in Sql Server 2008

In short description the Table Valued Parameters are used to pass a Table as a Parameter to a Stored procedure in Sql Server 2008. This helps to avoid comma seperated values to be passed to a parameter.

How To Split String Using Function in Sql server

How To Split String Using Function in Sql server, Sql server String Split function, Split function, Delimiter using Split function in sql server, split string function for Sql server, Create function for split string in sql server. Code for Split String Using Function in Sql server.

Get insert, update and delete script in sql server

We will code each and every time when we go for an insert, update and delete. This Sql function would get you the insert, update and delete script for the table name you passed to the function. Find the code to Get insert, update and delete script in sql server.

Round Function Example and Usage in sql

In this article I am going to explain about the Round function in sql.How it will be working in sql and how to use Round function in sql(in my point of view).i have given some more examples here about the round functions.Please read and use it your application whenever it is required. Learn Round Function Example and Usage in sql

“ COALESCE “ Method in Sql Server

During Development we have use more time Colesce method. If someone have home address or office address suppose if you dispaly available first record means you can use coalesce method, or, concatinate columns we use this coding. Learn COALESCE Method in Sql Server.

Function to get Number of Days in a month

This function will help to get the Number of days in a given month. The function returns the Number of days from the date given as input. The advantage of the function is that it returns the days of a month for all years(including Leap years)

Submit Your Article