Posts

Showing posts with the label SQL Server 2012

SQL Server database is Case In-Sensitive - is a MYTH!

The case sensitivity or insensitivity depends on the collation applied to the column or at the DB level .. Normally, the default collation is ‘CI’ but please remember it is not always ‘Case Insensitive’  If you run the below query on any particular db server .. SELECT SERVERPROPERTY ( 'COLLATION' )   what you could retrieve the data value, normally would be,  Latin1_General_CI_AS  (CI – Case Insensitive, AS – Accent Sensitive) But it could also be something like this …   Latin1_General_CS_AS  (CS – in this case, it is Case Sensitive)        So though it may take an additional 1/100 th of a nano-second, I'd generally prefer to UPPERize the string comparison such as below … UPPER(SUBSTRING ( COMMENT_ , 1 , 8 )) = ' Schedule '  instead of exact match such as SUBSTRING(COMMENT_, 1, 8) = 'Schedule'

SQL Server 2012 | Sequence Feature

Sequence feature which has been in Oracle for a number of years is now available in MS SQL 2012! A Sequence object is an object that provides functionality similar to Identity (Autonumber) column. The sequence object can be used with more than one table which is not possible in identity object. This is useful when you have parent-child tables and you want to know the value of the ID column before you insert records . A sample example is as follows: Sample 1: create sequence dbsequence start with 1 increment by 5 select next value for dbsequence --output=1 select next value for dbsequence --output=6 1.1    Should you need to clean up … drop sequence dbsequence Sample 2.1: create sequence idsequence start with 1 increment by 3 create table Products_ext ( id int, Name varchar(50) ) INSERT dbo.Products_ext (Id, Name) VALUES (NEXT VALUE FOR dbo.idsequence, 'ProductItem1') INSERT dbo.Products_ext (Id, Name) VALUES (NEXT...