Showing posts with label MS Sql Server. Show all posts
Showing posts with label MS Sql Server. Show all posts

Saturday, July 16, 2011

Juneau : Microsoft SQL Server Developer Tools

Microsoft announce new SQL Server tools, code named "Janeau" CTP 3 on 13th June 2011. For install "Janeau" is required Visual Studio 2010 SP 1. The operating system is required vista sp2 or above, Windows 7, Sql Server R2 SP 2. From bellow link you can download "Janeau" from microsoft.

Janeau Download Link

Microsoft provide nice video series for get starting with "Janeau". So here I share one of them video regarding "Janeau" integrate with visual studio via entity framework.




More Video refer bellow link

Wednesday, June 22, 2011

NEWID() - Generate Randomly Sort Records - TSQL

NEWID() - Generate Randomly Sort Records - TSQL

In our company, we have project for "Quiz management". On quiz page, we have to fetch 10 random question from large table. To get a random question, you might be tempted to select the top n rows from the table. However, this question is not random. The first n rows are not necessarily representative of the whole table. After few searches on MSDN, we found wonderfull solution. The solution here is the NEWID function, which generates a globally unique identifier (GUID) in memory for each row. By definition, the GUID is unique and fairly random; so, when you sort by that GUID with the ORDER BY clause, you get a random ordering of the rows in the table.

For that we use bellow query, which generate 10 random question each time. For testing we run them 3 times and code as per bellow.

Code :
SELECT TOP 10  *   FROM questions ORDER BY NEWID();

Friday, June 17, 2011

History Of MS SQL Server

SQL Server 2008 R2 is the latest version of a database server product that has been evolving since the late 1980s. Microsoft SQL Server originated as Sybase SQL Server in 1987. 

In 1988, Microsoft, Sybase, and Aston-Tate ported the product to OS/2. Later, Aston-Tate dropped out of the SQL Server development picture, and Microsoft and Sybase signed a co-development agreement to port SQL Server to Windows NT. The co-development effort cumulated in the release of SQL Server 4.0 for Windows NT. After the 4.0 release, Microsoft and Sybase split on the development of SQL Server; Microsoft continued forward with future releases targeted for the Windows NT platform while Sybase moved ahead with releases targeted for the UNIX platform, which they still market today. 

Delete VS Truncate

"What is deference between Delete & Truncate ? " 

We all face this question in interview at least once in our career. Actually it is very tricky question. We have many misunderstanding regarding this two terms. After lots of searching today I found some good comparison between them. It is as per bellow.

Delete Truncate
Removes rows from a table or view. DELETE statements delete rows one at a time, logging each row in the transaction log, as well as maintaining log sequence number (LSN) information. Removes all rows from a table without logging the individual row deletions.
TRUNCATE TABLE is similar to the DELETE statement with no WHERE clause; however, TRUNCATE TABLE is faster and uses fewer system and transaction log resources.
You may use DELETE statement against a view (with some limitations). You can’t use TRUNCATE statement against a view.