Posts

Nice article - "The Internet of Things and the cloud"

This is a nice article related to internet and cloud , its titled "The Internet of Things and the cloud" http://gigaom.com/cloud/alex-salkever-on-the-internet-of-things/

MSDN Magazine October Edition

The MSDN Magazine October edition is available. Check out here http://msdn.microsoft.com/en-us/magazine/hh463583.aspx

ASP.NET vNext Series by Scott Gu

Check out the articles on the ASP.NET vNext Series by Scott Gu at  http://weblogs.asp.net/scottgu/archive/2011/08/31/asp-net-vnext-series.aspx

Types of Cursors in SQL SERVER

The types of Cursors are as mentioned below Static The static cursors are those where the data on retrieval is not modified and remains as before it entered the cursor since its stored in the tempdb. This is also know as read-only cursors. Forward The forward only cursors can move forward in the result set. Dynamic The dynamic cursors identify all changes to data inside of the cursor or from outside by other users. If a particular data in a row was changed after that dataset was assigned to cursor, when that rows comes up we do see the modified data. Keyset-Driven The keyset cursors is such that when the cursor is open it will see the modifications happened for any row outside by other user before assigned to the cursor but will not see new records added.

8 years of Blogging

I was just thinking that it has been 8 years since i started blogging, time passes so fast. Just wanted to put down the number of blog post i have written in all these years 2003 - 2004 => 8 2004 - 2005 => 0 2005 - 2006 => 0 2006 - 2007 => 31 2007 - 2008 => 28 2008 - 2009 => 55 2009 - 2010 => 26 2010 - 2011 => 61 From above it looked like in the initial days i was not blogging much. For 2 years i had another blog which is no more available due to which this blog had no entries. Also due to hectic work schedules, i was not able to blog as well. I feel this year has been good and one of the highest number blog posts. Of late i am more on twitter ( @shaju  ) as well. I am hope in the coming days i will try to keep the same momentum, to increase this count as well. I wish many more readers come to my blog in the coming days. 

Cursors in SQL SERVER

We may need to do some operation each record wise in the record set returned. This is reason for cursors. The Syntax is as follows DECLARE cursor_name [ INSENSITIVE ] [ SCROLL ] CURSOR FOR select_statement [ FOR { READ ONLY | UPDATE [ OF column_name [ ,...n ] ] } ] [;] The below example shows that we need to print the employee name and employee id in a specific manner as Robert Smith (1000) DECLARE @ EmployeeID int DECLARE @Name varchar (100) DECLARE cursor_name CURSOR FOR SELECT EmployeeID , FirstName + ' ' + LastName FROM Employee OPEN cursor_name FETCH NEXT FROM cursor_name INTO @ EmployeeID , @Name WHILE @@FETCH_STATUS = 0 BEGIN   PRINT @Name + '(' + Convert( varchar (10), @ EmployeeID ) + ')'   FETCH NEXT FROM cursor_name   INTO @ EmployeeID , @Name END CLOSE cursor_name       DEALLOCATE cursor_name

Partition Information in SQL SERVER

Partition Function Information The Partition Function Information is obtained from the sys.partition_functions table as shown below SELECT * FROM SYS.PARTITION_FUNCTIONS Partition Range Information The Partition Range information is obtained from the sys.partition_range_values as shown below SELECT * FROM SYS.PARTITION_RANGE_VALUES Partition Scheme Information The Partition Scheme information is obtained from the sys.partition_scheme as shown below SELECT * FROM SYS.PARTITION_SCHEME Partitions Information The Partition information can be obtained from the sys.partitions table as shown below . SELECT * FROM SYS.PARTITIONS

Dropping of Partition in SQL SERVER

Drop a Partition Function To drop a partition function it should not have any partition scheme associated with it. The Syntax is as follows   DROP PARTITION FUNCTION < Partition Function Name  > The below example shows how to drop a partition function   DROP PARTITION FUNCTION EmployeePartitionLeft Drop a Partition Scheme To drop a partition scheme it should not have any table associated with it . The Syntax is as follows   DROP PARTITION SCHEME < Partition Scheme Name > The below example shows how to drop a partition scheme   DROP PARTITION SCHEME EmployeePartitionScheme

ASP.NET MVC 4 Developer Preview Released

I just happened to see this on Phil Haack's blog that the ASP.NET MVC 4 Developer Preview Released. Check out for more at   http://haacked.com/archive/2011/09/14/asp-net-mvc-4-developer-preview-released.aspx

How To Use Twitter With Facebook

If you want your tweets from twitter to update facebook, then check out this article on how to achieve the same  https://support.twitter.com/articles/31113-how-to-use-twitter-with-facebook

Altering Partition Scheme in SQL SERVER

§ The partition scheme is altered to add new filegroup which may be required when partitions are splitted . § The Syntax is as follows   ALTER PARTITION SCHEME   NEXT USED < Filegroup Name > § The below example shows how it associates a new filegroup FG4 to the partition scheme.    ALTER PARTITION SCHEME  EmployeePartitionScheme NEXT   USED           EmployeePartitionFG3

Nice Articles to Read

I came across these good articles. Do read when you have time 30 Ways to Quickly Improve Your Life Experience - http://advancedlifeskills.com/blog/30-ways-to-quickly-improve-your-life/ 10 Simple Ways to Be More Likable - http://advancedlifeskills.com/blog/be-more-likable/ 5 Ways to Keep Clutter Under Control - http://advancedlifeskills.com/blog/5-ways-to-keep-clutter-under-control/

Merging of a Partition in SQL SERVER

§ The partitions can be merged by merging the partition ranges. The partition range value mentioned will merge that to the next greater partition range value into a singe partition. § The syntax is as follows   ALTER PARTITION FUNCTION partition_function_name () {   SPLIT RANGE ( boundary_value ) | MERGE RANGE (   boundary_value ) } [ ; ] § The below shows the example for the same         ALTER PARTITION FUNCTION EmployeePartitionLeft ()   MERGE RANGE(150)

Adding New Partition in SQL SERVER

The adding of a new partition is nothing we are splitting an existing one and creating another out of that. The splitting is done by using the alter partition command. We have to note that before we split the partition there should be a additional filegroup already associated in the partition scheme. If there is no unused filegroup available then we cannot split. So before splitting we have to ensure that a filegroup is added to the partition scheme The syntax is as follows ALTER PARTITION FUNCTION partition_function_name() { SPLIT RANGE ( boundary_value ) | MERGE RANGE ( boundary_value ) } [ ; ] The below example shows how to add a new partition by the SPLIT option  ALTER PARTITION FUNCTION EmployeePartitionLeft () SPLIT RANGE (150)

Querying a Partitioned Table in SQL SERVER

1. Querying the data from a particular partition The Syntax is as follows SELECT …/* FROM WHERE $PARTITION. ( ) = The Partition number refers to first partition range or second partition range and so on, The first partition range is referred as 1 , second as 2 and so on. The below examples returns all the records in the partition 1. SELECT * FROM EMP WHERE $PARTITION.EmployeePartitionLeft (EMPLOYEEID) = 1 2. Querying for Knowing the Partition Number The syntax is as follows SELECT $PARTITION. ( ) = The below example returns 2 as the partition number for partition range >1 and less than equal to 100. SELECT $PARTITION.EmployeePartitionLeft(100) 3. Querying to find the count of records in each partition The syntax is as follows SELECT $PARTITION. ( ), COUNT(*) FROM GROUP BY $PARTITION. ( ) The below example returns the number of records in each partitions. SELECT $PARTITION.EmployeePartitionLeft (EMPLOYEEID) AS Partition, COUNT(*) AS [COUNT] FROM EMPLOYEE GROUP BY $PARTITION...

Partitioned Tables in SQL SERVER

The final step during the process of creating partition is to create the partitioned table. The below example shows the creation of Partitioned Tables Create Table Employee( EmployeeID int PRIMARY KEY, FirstName varchar(50), LastName varchar(50), Sex char(1), Age int CONSTRAINT df DEFAULT 18, DateOfBirth DateTime) ON EmployeePartitionScheme (EmployeeID)

Partition Schema in SQL SERVER

This is needed for associating the partitions to a specific filegroups. This is the second step in creating partitions. The Syntax is as follows CREATE PARTITION SCHEME AS PARTITION TO ( , ,….) The example below shows the creation of the same CREATE PARTITION SCHEME EmployeePartitionScheme AS PARTITION EmployeePartitionLeft TO ([EmployeePartitionFG1], [EmployeePartitionFG2], [PRIMARY]) The below example shows if all reside on the same filegroup   CREATE PARTITION SCHEME EmployeePartitionScheme AS PARTITION EmployeePartitionLeft ALL TO (EmployeePartitionFG1)

Partition Function in SQL Server

The partition function is created for setting the range partitions. The ranges can be set for a lower or upper threshold. This is the first step in creating partitions The syntax is as follows CREATE PARTITION FUNCTION ( ) AS RANGE LEFT/RIGHT FOR VALUES ( , ,…) LEFT : This specifies the maximum value of the first partition RIGHT : This specifies the minimum value of the second partition. The below examples shows creating a partitions as follows Partition 1 : column1 Partition 2 : column1 > 1 and column1 Partition 3 : column1 > 100 and column1 Partition 4 : column1 > 1000 CREATE PARTITION FUNCTION EmployeePartitionLeft (int) AS RANGE LEFT FOR VALUES (1, 100, 1000) The below examples shows creating a partitions as follows Partition 1 : column1 Partition 2 : column1 >= 1 and column1 Partition 3 : column1 >= 100 and column1 Partition 4 : column1 >= 1000 CREATE PARTITION FUNCTION EmployeePartitionRight (int) AS RANGE RIGHT FOR VALU...

Partitioning Tables in SQL SERVER

Partitioning is helpful for managing and accessing smaller chunks of data very efficiently and at a faster pace without compromising on data integrity. SQL Server supports Range Partitions. This means that the partitioning is based on data ranges.

Error Information Details in SQL SERVER

To know more about the error information, we can use the below mentioned functions 1. ERROR_NUMBER() returns the number of the error. 2. ERROR_SEVERITY() returns the severity. 3. ERROR_STATE() returns the error state number. 4. ERROR_PROCEDURE() returns the name of the stored procedure or trigger where the error occurred. 5. ERROR_LINE() returns the line number inside the routine that caused the error. 6. ERROR_MESSAGE() returns the complete text of the error message. As discussed in my previous post the divide by zero error can be seen using the error information functions. CREATE PROCEDURE GenerateDetailedException AS BEGIN BEGIN TRY SELECT 1/0 END TRY BEGIN CATCH SELECT ERROR_NUMBER() AS ErrorNumber ,ERROR_SEVERITY() AS ErrorSeverity ,ERROR_STATE() AS ErrorState ,ERROR_PROCEDURE() AS ErrorProcedure ,ERROR_LINE() AS ErrorLine ,ERROR_MESSAGE() AS ErrorMessage; END CATCH END