Cannot ALTER TABLE in MS SQL 2008/SQL2008 R2/SQL2012

Cannot ALTER TABLE in MS SQL After installing ms sql 2008/2012 you may face new problem which may protect you to alter any table. Something like following There is a new option added in SQL Server 2008/2012 for modifying tables while using the Table Designed in Management Studio which will prevent saving any changes to

Read More

Selecting Record from XML Valued Column in MS SQL

Just Consider we have following records in a object named CR_NonDPC_ConfigDTO PCName : PC MotherBoard : ASROK 945 GCM Processor : Pantium HDD : HDD 160 GB RAM : DDR-2 1 GB Cassing : NULL ExtraConfig : CD ROM ASUS Now we shall convert it to XML (for converting Object to XML you can check

Read More

Executing *.sql file form C#

Sometimes we need to run *.sql script from our application for installing data base. SqlCommand is not right for running installation script because installation script consists of DDL and GO command. Here we use smo library for executing *.sql script. For doing above operation we need to add following references Microsoft.SqlServer.ConnectionInfo Microsoft.SqlServer.Smo Took me a

Read More

Split in MS SQL SERVER

Here I shall describe about split in MS SQL. There is no built in function for splitting your text, that’s why I am describing two customize function for performing split operation in MS SQL. Split function 1: This function returns table that’s why we can say it table valued function. –select * from fnSplit(‘1,22,333,444,,5555,666’, ‘,’)

Read More

STUFF IN MS SQL, Getting data from table in a single row separated by comma or other sign

Consider following SQL statement for MS SQL Select UserName from UserInfo It will return UserName Anis Hasibul If you want to get these record in following way UserName Anis, Hasibul Then you have to use STAFF Consider following example of staff for getting above data SELECT STUFF ( (Select TOP 100 PERCENT ‘,’ + UserName

Read More