Hossein Zahed

Web Developer, Entrepreneur, Software Educator

Difference between TIMESTAMP and UNIQUEIDENTIFIER in SQL Server

No. TIMESTAMP  UNIQUEIDENTIFIER 
1 Size of TIMESTAMP value is 8 bytes. Size of UNIQUEIDENTIFIER is 16 bytes.
2 TIMESTAMP is not based on system date or time. UNIQUEIDENTIFIER value is based on the computer's MAC addresses and system date time.
3 The purpose to TIMESTAMP is to track the operation in tables on the database level. The purpose of UNIQUEIDENTIFIER is to have a unique value assigned to a row (maybe as primary key). It remains unique in any system in the world.

How to determine the version and edition of SQL Server and its components

I typically use this SQL query:

SELECT  
    SERVERPROPERTY('productversion') as 'Product Version', 
    SERVERPROPERTY('productlevel') as 'Patch Level',  
    SERVERPROPERTY('edition') as 'Product Edition',
    SERVERPROPERTY('buildclrversion') as 'CLR Version',
    SERVERPROPERTY('collation') as 'Default Collation',
    SERVERPROPERTY('instancename') as 'Instance',
    SERVERPROPERTY('lcid') as 'LCID',
    SERVERPROPERTY('servername') as 'Server Name'

This lists your server version, edition, service pack (if applicable) etc.

IEnumerable Vs IQueryable

Many  developers gets confused between IEnumerable and IQueryable. When it comes to writing code, both looks very similar. However there are many difference between them which needs to be taken care of while writing code. Both have some intended usability scenarios for which they are made.

Below lists the differences between them based on their properties :

 

  IEnumerable  IQueryable
Namespace System.Collections Namespace System.Linq Namespace
Derives from No base interface Derives from IEnumerable
Deferred Execution Supported Supported
Lazy Loading Not Supported Supported
How does it work While querying data from database, IEnumerable execute select query on server side, load data in-memory on client side and then filter data. Hence does more work and becomes slow. While querying data from database, IQueryable execute select query on server side with all filters. Hence does less work and becomes fast.
Suitable for LINQ to Object and LINQ to XML queries. LINQ to SQL queries.
Custom Query Doesn’t supports. Supports using CreateQuery and Execute methods.
Extension mehtod
parameter
Extension methods supported in IEnumerable takes functional objects. Extension methods supported in IEnumerable takes expression objects i.e. expression tree.
When to use when querying data from in-memory collections like List, Array etc. when querying data from out-memory (like remote database, service) collections.
Best Uses In-memory traversal Paging