Posts

Showing posts from 2011

End of 2011 and Beginning of 2012

The memories of the last new year 2011 is so fresh in my mind. It just shows how quick the year passed by. There has been always high's and low's in a year. On the professional front i did get a promotion. I did learn new stuff's on the technology front, but not to my expectation. The past year i have been little active on the social media (Twitter, Facebook). On the blog front, i could only manage to make 68 posts. On the personal front i did not take any vacations, that looks bad. On the Spiritual front, i did attend a couple of fasting prayers, sunday services and prayer meetings. Now the past is past, we can only look for a better tommorrow. Hope this year, will try to achieve things i could not in the last year. I am not planning to make any resolutions. I believe the guarding angels will be with me this year and praying to god to help me all my works. Wishing a Blessed and Prosperous Happy New Year 2012 to all my colleagues, readers, family and friends.

“Unable to retrieve the metadata for …” Error while using ASP.NET MVC 3

While adding a controller in ASP.NET MVC 3 application, you might get a error “Unable to retrieve the metadata for …”. This error is due to the incorrect connection string name or the connection string in the web.config. I had encountered the same error and the issue was that the name of my DBContext was different from that of the web.config connection string name. When I made it same it was able to create the controller.

jQuery Mobile

jQuery Mobile 1.0 is released. This is a HTML5 based UI system for all the major mobile device platforms. To  know more about check  http://jquerymobile.com/  .

Node.js on windows

In order to install Node.js and build application on windows follow the steps mentioned below 1. First you can download the WebMatrix from http://www.microsoft.com/web/gallery/install.aspx?appid=webmatrix , if you need it. 2. Download the node.js for windows from http://nodejs.org/ 3. Install the iisnode for the web server a. iisnode for iis7 express - http://go.microsoft.com/?linkid=9784329 b. iisnode for iis7 x86 - http://go.microsoft.com/?linkid=9784330 c. iisnode for iis7 x64 - http://go.microsoft.com/?linkid=9784331 , you may need to install the C++ 2010 redistributable for x64 from http://www.microsoft.com/download/en/details.aspx?id=14632 4. Steve's node.js templates can be downloaded from  https://github.com/SteveSanderson/Node.js-Site-Templates-for-WebMatrix/downloads Now open WebMatrix and choose sites from template. Then choose a Node.js template and run the application. There you go, it should work.

Learn Javascript Courses

To learn Javascript courses, try Codecademy at  http://www.codecademy.com/  . This is a nice site to learn javascript.

Nice Article on HTML5

Read this nice article titled "Better Web Forms with HTML5 Forms" at  http://msdn.microsoft.com/en-us/magazine/hh547102.aspx

FireFox 8 to be launched on Nov 8

FireFox 8 will be launched on Nov 8. Firefox 8 Launches In Two Days, But Here's How To Get It NOW, Read at http://www.businessinsider.com/download-firefox-8-2011-11 "Firefox 8, which comes just six weeks after the launch of Firefox 7, includes some slick new features. There's Twitter embedded in the search bar, better add-on management, much improved tabs, support for HTML 5 context menus, and a lot more."

MSDN Magazine November Edition

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

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 < Column Name1 >…/* FROM < Table Name > WHERE $PARTITION.< Partition Function Name >(< Column Name >) = < Partition Number > 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.< Partition Function Name >(< Column Name >) = < Partition Range Value > 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.< Partition Function Name >(

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 < Partition Function Name > TO (< Filegroup1 >,< Filegroup2 >,….) 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 < Function Name > (< DataType >) AS RANGE LEFT/RIGHT FOR VALUES (< value1 >,< value2 >,…) 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 <= 1 Partition 2 : column1 > 1 and column1 <= 100 Partition 3 : column1 > 100 and column1 <= 1000 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 < 1 Partition 2 : column1 >= 1 and column1 < 100 Partition 3 : column1 >= 100 and colu

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

Exception Handling in SQL SERVER

Exception Handling is a practice to capture the error efficiently and display the error in a well formatted way. In SQL Server, we use the TRY..CATCH Block for handling exceptions. The syntax is as follows BEGIN TRY       { sql_statement | statement_block } END TRY BEGIN CATCH       [ { sql_statement | statement_block } ] END CATCH [ ; ] The below shows an exception message for divide by zero error CREATE PROCEDURE GenerateException AS BEGIN BEGIN TRY SELECT 1/0 END TRY BEGIN CATCH SELECT 'Error Occurred' END CATCH END

@@ERROR in SQL SERVER

@@ERROR returns zero if the last executed statement did not throw an error, else it will return an error number. The below shows a error message with error number when an Divide by Zero is encountered. CREATE PROCEDURE ErrorNumber AS BEGIN DECLARE @ErrorNumber varchar(20) SELECT 1/0 SET @ErrorNumber = @@ERROR PRINT 'Error Generated : ' + @ErrorNumber END

RAISERROR in SQL SERVER

RAISERROR will use the built-in messages in sys.messages view or dynamically generated error message. The Syntax is as follows RAISERROR ( { msg_id | msg_str | @local_variable }     { ,severity ,state }      [ ,argument [ ,...n ] ] )     [ WITH option [ ,...n ] ] Severity 0 – 18 , Can be raised by any user Severity 19 – 25, Can be raised by those who have sysadmin role. State : This is a integer value between 0 to 255 The below shows an error message if the employee id does not exists CREATE PROCEDURE GenerateError(@EmployeeID int) AS BEGIN If exists(SELECT 1 FROM employee WHERE EmployeeID = @EmployeeID) BEGIN SELECT * FROM Employee WHERE EmployeeID = @EmployeeID END ELSE BEGIN RAISERROR ('Employee ID does not exists', 10, 2) END END

Dropping User-Defined Functions

To delete a function we need to use the drop function The Syntax is as follows DROP FUNCTION < FunctionName > The below shows how to drop a function DROP FUNCTION USFORMATPHONE

Altering User-Defined Functions

We can modify the user defined functions by using the Alter command. The Syntax as shown below Scalar-valued Functions ALTER FUNCTION [ schema_name. ] function_name ( [ { @parameter_name [ AS ][ type_schema_name. ] parameter_data_type     [ = default ] }     [ ,...n ]   ] ) RETURNS return_data_type     [ WITH [ ,...n ] ]     [ AS ]     BEGIN         function_body         RETURN scalar_expression     END [ ; ] Table-valued Functions ALTER FUNCTION [ schema_name. ] function_name ( [ { @parameter_name [ AS ] [ type_schema_name. ] parameter_data_type     [ = default ] }     [ ,...n ]   ] ) RETURNS @return_variable TABLE     [ WITH [ ,...n ] ]     [ AS ]     BEGIN         function_body         RETURN     END [ ; ] The below shows how a function has been modified to change the message ALTER FUNCTION USFORMATPHONE(@PhoneNumber varchar(25)) RETURNS Varchar(50) AS BEGIN DECLARE @phone varchar(50) IF(LEN(@PhoneNumber) = 10) SET @phone = '('+ SUBSTRING(@PhoneNumber,1,3) + ')&#

Table-Valued User Defined Function in SQL SERVER

We will look into the Table-Valued User Defined Function The syntax for Table-Valued is as follows CREATE FUNCTION [ schema_name. ] function_name ( [ { @parameter_name [ AS ] [ type_schema_name. ] parameter_data_type     [ = default ] [READONLY] }     [ ,...n ]   ] ) RETURNS @return_variable TABLE      [ WITH [ ,...n ] ]  [ AS ]      BEGIN          function_body          RETURN      END [ ; ] The below example shows how to create a multistatement table-valued function which provides details based on the department status. CREATE FUNCTION DEPT_DETAILS_BY_STATUS(@Status varchar(10)) RETURNS @DEPTSTATUS TABLE ( DEPTID int, DEPTNAME varchar(100), STATUS varchar(10) ) BEGIN INSERT INTO @DEPTSTATUS Select * from Dept where Status = @Status RETURN END The usage of the same is as follows Select EmployeeID, FirstName, LastName, Dt.DeptName from Employee INNER JOIN DEPT_DETAILS_BY_STATUS('Active') Dt ON Dt.DeptID = Employee.DeptID

Jesus - God Thinks of you.

I received this mail and i thought its really worth to share. JESUS VS. Satan Satan went to visit Jesus in the Garden of Eden, and Satan came all happy and boasting. (Lk 4: 1-12; Job 1: 6-12) "Yes, Lord, now I have everybody captive, (well nearly everybody down there). I set traps, I used the baits of temptation, I know well what each one of them can't resist. I nearly caught them all!" (I Pet 5: 8-9; Eph 6: 10-17) "What are you going to do with them?" Jesus asked. and He was praying to God the Father. Satan answered "Oh, I am going to have some fun with them!" I'll make them divorce after they have married so the foundation of humanity will never be able to be established "the family" (Mt 19: 4-6; Mal 2: 16 ) I will make them hate each other and abuse each other, make them fall into alcohol and drugs without control. (Rom 13: 12-14) I will teach them to make weapons and bombs, so they kill each other "I am really going to have

Scalar-Valued User Defined Function in SQL SERVER

We will look into the Scalar-Valued User Defined Function The syntax for Scalar-Valued is as follows CREATE FUNCTION [ schema_name. ] function_name ( [ { @parameter_name [ AS ][ type_schema_name. ] parameter_data_type     [ = default ] [ READONLY ] }     [ ,...n ]   ] ) RETURNS return_data_type     [ WITH [ ,...n ] ]      [ AS ]      BEGIN          function_body          RETURN scalar_expression      END [ ; ] The below example shows how a function returns the phone number in US Phone format (XXX)XXX-XXXX CREATE FUNCTION USFORMATPHONE(@PhoneNumber varchar(25)) RETURNS Varchar(50) AS BEGIN DECLARE @phone varchar(50) IF(LEN(@PhoneNumber) = 10) SET @phone = '('+ SUBSTRING(@PhoneNumber,1,3) + ')' + SUBSTRING(@PhoneNumber,4,3) + '-' + SUBSTRING(@PhoneNumber,7,4) ELSE SET @phone = 'Invalid Phone Number' Return @phone END The usage of the same is as follows SELECT EMPLOYEE.DBO.USFORMATPHONE ('1234567890')

Lunch @Benito's

This afternoon had been for a team lunch with my colleagues to Benito's . It was a nice place with some great food. Especially there Benito's special soup, sizzlers .. . A good place to visit..

User-Defined Functions in SQL SERVER

User-Defined Functions are nothing but a program that accepts parameters and returns a type of result. There are two types of User Defined Functions 1. Scalar-Valued 2. Table-Valued

Table Variables

1. Table variables are similar to the normal tables or temporary tables. 2. This is good if you don’t want to store large data for temporary use. 3. These are only available during the execution of the program. 4. The Syntax is as follows DECLARE @< Variable_Name > TABLE >(< ColumnName1 > < Datatype >,< ColumnName2 > < Datatype >…) 5. The below shows the example to use table variables DECLARE @temp_employee TABLE(EmployeeID int PRIMARY KEY, FirstName varchar(50), LastName varchar(50), Sex char(1), Age int DEFAULT 18, DateOfBirth DateTime) SELECT * FROM @temp_employee

Temporary Tables

1. Temporary Tables are similar to tables unlike they are life is only for the current session and it will be automatically dropped after that. 2. This is very useful for storing some information during a large computations temporarily instead of using physical tables. 3. They cannot have foreign key constraints. 4. It is stored in the TempDB. 5. The Syntax is CREATE TABLE #< TableName >(< ColumnName1 > < Datatype >,< ColumnName2 > < Datatype >…) 6. The below shows an example how to create a temporary table CREATE TABLE #tempEmployees(EmployeeID int PRIMARY KEY, FirstName varchar(50), LastName varchar(50), Sex char(1), Age int CONSTRAINT df DEFAULT 18, DateOfBirth DateTime)

Derived Tables

1. Derived Tables are nothing but using a result of a query as a table. 2. This is much better than using temporary tables. 3. This increases the performance. 4. The below shows how to return employee and department info for those who don’t belong to a inactive department Select EmployeeID, FirstName, LastName, Dt.DeptName from Employee INNER JOIN (Select * from Dept where Status !='InActive') Dt ON Dt.DeptID = Employee.DeptID

Common Table Expressions (CTE) in SQL SERVER

1. Common Table Expressions are similar to that of a Derived Table. 2. We can define a CTE and use it multiple times in a query unlike Derived Tables. 3. The number of columns in the expression should be similar to that of the query result used in CTE. 4. CTE can be used recursively also. The Syntax is as follows WITH expression_name [ ( column_name [,...n] ) ] AS ( CTE_query_definition ) The below example demonstrate the use WITH Dt_CTE (DeptID, DeptName, Status) AS (Select * from Dept where Status !='InActive') Select EmployeeID, FirstName, LastName, Dt.DeptName from Employee INNER JOIN Dt_CTE Dt ON Dt.DeptID = Employee.DeptID

Limitations of XML Datatype

The Limitations for XML Datatype is as follows 1. The size of the XML datatype cannot exceed 2GB. 2. We cannot cast or convert to text or ntext. 3. The column of XML datatype cannot be sorted or we can not group the same using GROUP BY. 4. This cannot be passed as parameters to be used with scalar or built-in function except with ISNULL, COALESCE, and DATALENGTH. 5. This cannot be used as a column that can have an Index. But we can add a non-clustered index using the INCLUDE keyword.

Office 2010 and Sharepoint 2010 Service Pack 1 is released

Office 2010 and Sharepoint 2010 Service Pack 1 is released. Check out here http://blogs.technet.com/b/office_sustained_engineering/archive/2011/06/28/announcing-office-2010-and-sharepoint-2010-service-pack-1-availability.aspx

Disabling RadioButtonList Control List Item

When working with a RadioButtonList control and if you wish to disable one of the list items in it , the very obvious solution would be as mentioned below radioList.Items[1].Enabled = false; But to surprise this does not work. Bingo...the solution to this problem is to use as mentioned below radioList.Items[1].Attributes.Add("disabled", "disabled"); Happy Coding....

XML Datatype Method – nodes()

The nodes() method is useful when you want to shred an xml data type instance into relational data means it will be mapped into a new row. The syntax is nodes (XQuery) as Table(Column) The below shows how to display the xml data in relational data in different rows. SELECT JobHistory.query('.')as nodes FROM Employee CROSS APPLY JobHistory.nodes('/Job') as MyNodes(a)

SQL SERVER code name "Denali" CTP 3 Download Available

The Microsoft SQL SERVER code name "Denali" CTP 3 is available to download at http://technet.microsoft.com/en-US/evalcenter/hh225126.aspx

On Google+

I received a invite for Google+ from my friend. On it now.. Exploring and i would say its a welcome change from Facebook. Lets explore more.

XML Datatype Method – exist()

The exist() method returns a bit as follows 1, this means the XQuery expression in a query returns a result which is at least a xml node. 0, this means it’s a empty result NULL, this means that it was executed against a NULL value. The Syntax is exist (XQuery) The below shows how to check if the JobID 1 exists SELECT JobHistory.exist('/Job[@JobID=1]') FROM Employee

XML Datatype Method – Value()

This performs an XQuery against the XML and returns a value of SQL type. This method returns a scalar value. The syntax is value (XQuery, SQLType) The below shows how to return the company name value of a varchar datatype SELECT JobHistory.value('(/Job/CompanyName)[1]','varchar(100)') FROM Employee

XML Datatype Method – Query()

The Query() method is used to query the XML data using XQuery Expression The Syntax is query ('XQuery') The below shows how to display the xml node where jobid is 1 SELECT JobHistory.query('/Job[@JobID=1]') FROM Employee The below shows how to display the company name node where jobid is 1 SELECT JobHistory.query('/Job[@JobID=1]/CompanyName/text()') FROM Employee

XML Datatype Methods

We can use the xml data type methods to modify/query an XML stored in a column of xml datatype. The methods are as follows 1. Modify() 2. Value() 3. Query() 4. Exist() 5. Nodes() Today, we will see the use of Modify() method The Modify() method is used to modify parts of the XML data in the XML column using XQuery Expression The Syntax is modify (XML_DML) The below example shows to add one more job node to the xml UPDATE Employee SET JobHistory.modify( 'insert < Job JobID="2"> < CompanyName>News Corp< /CompanyName> < Years>1< /Years> < /Job> after (/Job)[1]') WHERE EMPLOYEEID = 1 The below example shows to replace a value in the xml node. UPDATE Employee SET JobHistory.modify( 'replace value of (/Job/@JobID)[1] with 3') WHERE EMPLOYEEID = 1 UPDATE Employee SET JobHistory.modify( 'replace value of (/Job/CompanyName/text())[1] with "BBC Corp"') WHERE EMPLOYEEID = 1 The below example shows to delete a n

Using XML Datatype is SQL SERVER

The xml data type lets you store XML documents and fragments in a SQL Server database.  The below shows how to add a new column of XML datatype ALTER TABLE Employee ADD JobHistory XML The below shows how to Store the data in a XML column UPDATE Employee SET JobHistory= '< Job JobID="1" > < CompanyName>ABC Corp< /CompanyName> < Years>1< /Years> < /Job> ' WHERE EMPLOYEEID = 1

Use of sp_executesql

The "sp_executesql" is used for executing the sql statements that are build dynamically with or without parameters. The below example shows how to execute by dynamically passing the employee id. DECLARE @EmployeeNumber int; DECLARE @SQLString nvarchar(500); DECLARE @Parameter nvarchar(500); SET @SQLString = 'SELECT * FROM EMPLOYEE WHERE EMPLOYEEID = @EmployeeID'; SET @Parameter = '@EmployeeID int'; SET @EmployeeNumber = 2; EXECUTE sp_executesql @SQLString, @Parameter, @EmployeeID = @EmployeeNumber;

Dynamic SQL in SQL Server - Introduction

Dynamic SQL is nothing but SQL query that is generated programmatically. For example, we can get records of any table using the below Stored Procedure which implements Dynamic SQL CREATE PROC GETDETAILSBYTABLENAME(@TableName varchar(50)) AS BEGIN Declare @SQLQuery VarChar(5000) SELECT @SQLQuery = 'SELECT * FROM ' + @TableName Exec ( @SQLQuery) END

SSRS with XML as Data Source - An Option

I am sure we commonly use SQL SERVER Reporting Services(SSRS)using the Data Source as the database. But if we have think to use XML, then one of the options to use the XML would be to host the XML's in a virtual directory in IIS. Then access the same as a connection string in SSRS. We can think of various options as well.

HTML 5 Feature

We used to always close the tags like for eg: < label id="lblname" title="Name" /> Now in HTML 5 we can even write without closing tags < label id="lblname" title="Name" >

Office 365

Check out the new Office 365 which is flexible and easy in creating documents , maintaining calendar, emails. It is all managed my microsoft, which means it can be accessed from anywhere. It offers the pay as you go service. For more details read here http://www.microsoft.com/en-in/office365/online-software.aspx To know how it work click here http://www.microsoft.com/en-in/office365/online-software.aspx

New Structural Elements in HTML 5

The new structural elements in HTML 5 are 1. < header > - This is the header which may contain the introduction for a page or a section. 2. < nav > - This is reserved for the sections or pages that has links to other pages. 3. < section > - This is the generic document , more like the < div >. 4. < article > - This represent the main content area of the page. 5. < aside > - This can be referred to as the side bar of the page, where we usual have some about information, tags etc. 6. < footer > - This adds the footer information for the page. Hope this gives an idea on the structural elements in HTML 5.

Good Article - tips for getting more done in fewer hours

Came across this good article.. Read through http://gigaom.com/collaboration/7-tips-for-getting-more-done-in-fewer-hours/

Posting blog entries to Facebook

I use the application RSS Graffiti to post my blogs to Facebook. Here goes the first one :) ... More to come soon.

Running 32-bit application on a 64bit OS IIS 7

When we try to run a 32 bit application hosted on a 64bit OS IIS, it will throw an error that 32 bit application cannot be run. To execute the same go the Application Pool and select the advanced settings on the pool where your application is running. Then change the property "Enable 32-Bit Application" to "True". Bingo.. the application will start working.

Moved to 64-bit Windows 7

Moving from a 32 bit to 64 bit Windows 7 OS was a real shift. I had always been using a 32 bit. But for something that i noticed is that even we have a 4 GB RAM, the memory that was usable was ~2.9GB hence my application was getting slower. I could not even debug. When i shifted to 64 bit , I could see that the memory usable is now 3.8 GB. This was a great boost for performance. I see a lot of change in the way the memory is being used. More to explore.. will keep updating on this in future blog.

Page.RegisterStartupScript not working ??

I am sure many has gone through this where Page.RegisterStartupScript is not working. There are a couple of reasons, they are 1. If the page's form has no "runat=server" 2. If there is a update panel. This can be overcome by using ScriptManager.RegisterStartupScript 3. If there is someother javascript on the page.init Also the Page.RegisterStartupScript is obsolete, start using ClientScript.RegisterStartupScript Happy Coding....

HTML 5 - A First Look

This is been a buzz word these days HTML 5. I keep hearing from people that we should use HTML 5 . Is this just a new buzzword in the internet community or is it something new that will change the way we see web ????? Well….. lets discuss on the same. HTML 5 is the new new version of the Hyper Text Markup Language which is the standard language used for displaying contents with styles. The new HTML 5 brings in new elements and attributes to display modern capabilities on the websites. HTML 5 brings in backward compatibility which helps parsing of older versions of HTML. HTML 5 is no longer based on Standard Generalized Markup Language (SGML). It has the new DOCTYPE which is We will see more on this soon……

When to Tweet …….

I came across this good site www.whentotweet.com . This sites lets you know when is the best time for you to tweet. Have fun tweeting at the time prescribed :)

Trust in God..

Trusting in God is the way of life. Many people think that they achieve everything because of there might, ability and strength. I feel that whatever happens in your life is because of God’s will. We have to always keep our trust in God and everything in our life will happen at God’s time. Even at whatever urgency we show to get something done it may not succeed because we need Gods grace and only at his time it will come to pass. Every morning we should wake up with prayers and present before God the needs of your life. God will meet our desires at the appropriate time. We need to have patience and wait upon him till it comes to pass. Above all we should thank him for that he has done in our life. In all situation may be good or in worst situation we should seek his face and he will never let you down. For the instance you may feel why this is happening to you but very soon he will lift you up in front of the same people to higher places. He is an awesome god. I have personally felt a

One more year passed by - Happy Birthday

Getting older by one more year :) . yep. guessed it right.. it was my birthday yesterday. Spend the morning in church for fasting and prayer. It was awesome in the presence of God. At church we had Rev. Alwin Thomas (Ruah Ministries) and we had a good time of fellowship with our Lord and Saviour Jesus Christ. Lot of friends wished me and many wishes over email, SMS and facebook. Hope to have a great year ahead...... Cheers!!!

Happy New Year 2011

Its New Year 2011 that's 1/1/11 ...wow.. 2010 has passed by , a year filled with all ups and downs but truely the almighty God took care at all times. The promise for the year 2011 is "BE FRUITFUL" Genesis 28:3, I am sure this year is going to be fruitful by walking with presence of God. I am sure last year i was better in updating my blog.. Hope to better it this year. Wishing all a Happy and Prosperous NEW YEAR 2011.