Tech Support Websites

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Sunday, 29 January 2012

Notes from Pluralsight course - SQL Server Questions and Answers

Posted on 09:45 by Unknown
In the Pluralsight course "SQL Server Questions and Answers", Pinal & Vinod debunk some SQL Server misconceptions with examples and highlight uncommon facts -
  • Use SCOPE_IDENTITY() instead of @@IDENTITY or IDENT_CURRENT("tablename") to get the latest IDENTITY value for the table in the session
  • @@IDENTITY returns the last IDENTITY value produced on a connection
  • SCOPE_IDENTITY() returns the last IDENTITY value produced on a connection (explicity created by you rather than a trigger) and by a statement in the same scope
  • IDENT_CURRENT("tablename") returns the last IDENTITY value produced in a table, regardless of the connection
  • Identity column value can be positive or negative
  • Identity column can be reseeded with DBCC CHECKIDENT command
  • Deleting records from table using DELETE does not reset Identity values whereas deleting records from table using TRUNCATE resets Identity values.
  • TRUNCATE statements are logged and can be part of transaction. Such transactions can be rolled back.
  • Executing TRUNCATE is not possible when a table is referenced by a foreign key or if the table is used in replication or with Indexed views
  • WHERE can be used with SELECT, DELETE, UPDATE statements whereas HAVING is used along with GROUP BY clause in a SELECT statement
  • The order of the conditions in the WHERE clause does not affect index used. This can be verified from the Execution plan.
  • If parenthesis is used with a combination of OR & AND conditions, the result & index usage may vary
  • Table variables & Temporary tables both exist in TempDB
  • Table variables too can have a clustered index but they do not participate in the Transaction context.
  • A Table variable cannot be assigned to another Table variable
  • A Table variable cannot be truncated
  • Stored procedures are not compiled when created.
  • Stored procedures are compiled on first run & this can be verified by watching the SP:CacheInsert event in Profiler.
  • Using Filtered Index (uses WHERE in an UNIQUE INDEX) which is new in SQL Server 2008, it is possible to have multiple nulls even when UNIQUE constraint is imposed.
  • In SQL Server 2008, date and time can be stored independent of each other in a db using the DATE & TIME datatypes
  • DateTime2 datatype has a precision of 100th of a nanosecond.
  • Precision of SmallDateTime datatype is 1 minute
  • Multiple UNIQUE constraints can be defined on a table
  • A quick way to populate table rows - 
  • CREATE TABLE Test (id INT IDENTITY(1,1), Long_Name CHAR(7500) DEFAULT 'dummy') 
    INSERT INTO Test DEFAULT VALUES; GO 15; --inserts 15 rows
  • fn_dblog is an undocumented system UDF that lets you to read from your transaction log  
  • Lock duration is dependent on the ISOLATION LEVEL (READ COMMITTED, READ UNCOMMITTED, REPEATABLE READ, SERIALIZABLE)
  • When a nested transaction is rolled back it always rolls back to the outermost BEGIN TRANSACTION statement (unless SAVEPOINT is used)
  • DENY takes precedence over GRANT except at a column level GRANT
  • Blocked process report Event under Error & Warnings section of Events Selection tab in the Trace Properties dialog box in Profiler helps in analyzing Blocking issues
  • Recent Expensive Queries tab within Activity Monitor in SSMS shows queries that you can optimize.


Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in SQL Server | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Windows 8 keyboard shortcuts
    Win + X   - context menu to access common features like Control Panel, Task Manager, File Explorer, Programs & Features, Run, Search etc...
  • My 30-day personal project - watch 100 hours of Pluralsight videos
    Inspired by Matt Cutts' 30-day challenges , I plan to watch 100 hours of Pluralsight online videos to get up-to-date with current ...
  • Archive tweets & favorites with Google Reader
    There are numerous ways to archive tweets but rather than use yet another tool, I prefer using Google Reader to preserve the tweets I mark ...
  • Azure in Pictures - overview of Windows Azure Features, Services and Common Uses
    Download the Windows Azure Poster in PDF format (1.1MB)
  • What is the difference between Browser Mode & Document Mode in IE
    If you're a web developer and your job actively involves building web pages that work the same in all browsers including the last three ...
  • Dashboard-like info with Browser tabs, Windows 7 Taskbar tabs
    Browser tabs & Windows 7 Taskbar tabs are turning self-aware.  This is how my browser looked the other day: I had the summary of all tha...
  • 10 ways to make laptop battery last longer
    Paraphrased from a Right Choice magazine article with my own opinions: Keep the brightness of the screen as low as possible. If portability ...
  • India ranks fourth in Internet usage
    Deepak Shenoy informs that as per Telecom Regulatory Authority of India (TRAI) data, India has nearly 10 million Broadband connections in ...
  • HOW TO let Google watch over your web activity
    When we get onto the Internet, we trade our privacy for convenience. Everyone from marketers, ISPs to Governments can watch our activities o...
  • What's common between Kovid Goyal & Antony Lewis?
    Kovid Goyal Antony Lewis They are both PhDs in Physics and creators of free software applications that have been downloaded by millions. Kov...

Categories

  • AJAX
  • Android
  • APIs
  • App
  • ASP
  • ASP.NET
  • ASP.NET-MVC
  • Azure
  • Azure SQL Database
  • AzureInPictures
  • Bing
  • Book Review
  • Bookmarklet
  • Browsers
  • C#
  • chart
  • Chrome
  • Cloud
  • CSS
  • CSS3
  • DidYouKnow
  • E-Commerce
  • Excel
  • FB
  • Fiddler
  • Firefox
  • Gadgets
  • GeoLocation
  • GMail
  • Google
  • Google Docs
  • Google Reader
  • Health
  • Hotmail
  • HOWTO
  • HTML
  • HTML/CSS
  • HTML5
  • Humor
  • Hyderabad
  • IE
  • IIS
  • India
  • Internet
  • IT
  • Javascript
  • jQuery
  • JSON
  • JSONP
  • Laptop
  • Learning Resources
  • Lists
  • Map
  • Metrics
  • Microsoft
  • miscellaneous
  • Mobile
  • NAPA
  • Office365
  • Opera
  • PDF
  • Performance
  • Personal
  • PHP
  • PM
  • PowerShell
  • Privacy
  • Programming
  • Rant
  • Safari
  • Science
  • Search Engines
  • SearchEngines
  • Security
  • SEO
  • Sharepoint
  • SharePoint2013
  • Silverlight
  • Software Engineering
  • Solutions
  • SQL Azure
  • SQL Server
  • TFS
  • Tip
  • Tips
  • Tools
  • Tools/Utilities
  • Trivia
  • TWIL
  • Twitter
  • UX
  • VM
  • VS.NET
  • VS2010
  • VS2012
  • WCF
  • WebApps
  • Websites
  • WF
  • Windows Phone
  • Windows7
  • Windows8
  • Word
  • WP7
  • WPF

Blog Archive

  • ►  2013 (112)
    • ►  October (16)
    • ►  September (14)
    • ►  August (8)
    • ►  July (8)
    • ►  June (13)
    • ►  May (12)
    • ►  April (12)
    • ►  March (8)
    • ►  February (15)
    • ►  January (6)
  • ▼  2012 (127)
    • ►  December (11)
    • ►  November (14)
    • ►  October (13)
    • ►  September (14)
    • ►  August (16)
    • ►  July (16)
    • ►  June (6)
    • ►  May (5)
    • ►  April (11)
    • ►  March (12)
    • ►  February (7)
    • ▼  January (2)
      • Notes from Pluralsight course - SQL Server Questio...
      • Explore console.log if you use JavaScript alert ex...
  • ►  2011 (98)
    • ►  December (5)
    • ►  November (2)
    • ►  October (5)
    • ►  September (7)
    • ►  August (7)
    • ►  July (15)
    • ►  June (10)
    • ►  May (7)
    • ►  April (8)
    • ►  March (10)
    • ►  February (11)
    • ►  January (11)
  • ►  2010 (163)
    • ►  December (14)
    • ►  November (19)
    • ►  October (19)
    • ►  September (15)
    • ►  August (18)
    • ►  July (17)
    • ►  June (20)
    • ►  May (17)
    • ►  April (19)
    • ►  March (5)
Powered by Blogger.

About Me

Unknown
View my complete profile