SQL Server – SELECTing/Displaying Top N rows from a table
To SELECT only top N rows from a table we can use TOP clause in SELECT statement. Using TOP clause we can also specify percentage option. For example, both of these statements are valid: USE SqlAndMe...
View ArticleSQL Server – Import text file using xp_cmdshell
There are several options available to import data from external sources to SQL Server. Such as Import & Export Wizard, BULK INSERT command, SSIS and OPENROWSET. Apart from this options you can...
View ArticleSQL Server – Custom sorting in ORDER BY clause
ORDER BY clause can be used to sort the results returned by SELECT statement in SQL Server. It orders the result set by specified column list. When used with character data type columns it sorts data...
View ArticleSQL Server – Calculating elapsed time from DATETIME
Elapsed time can be calculated from DATETIME field by extracting number of hours/minutes and seconds. You can use below query to calculate elapsed time between two dates: -- Vishal -...
View Article