Monday, December 9, 2013

Read XML into SQL Database

Declare @xml XML
set @xml = (select cast(c1 as xml) from OPENROWSET (BULK 'XMLpath.xml',SINGLE_BLOB) as T1(c1))
insert into TableName (Col1,Col2,Col3)
SELECT A.Column1,A.Column2,A.Column3 FROM
(SELECT
       Tbl.Col.value('@XmlTag', 'varchar(200)') as Col1,
       Tbl.Col.value('@XmlTag', 'datetime')  as Col2,
       Tbl.Col.value('@XmlTag', 'varchar(2000)')  as Col3
FROM   @xml.nodes('//XMLNode') Tbl(Col) )  A

Friday, October 25, 2013

jQuery Mobile 1.4.0

The jQuery Mobile team is excited to announce the first release candidate for 1.4.0. For this new version of the jQuery Mobile framework we focused on performance improvements, reviewing widgets as well as a new default theme and SVG icons. Some of the new features in 1.4 are a flip switch widget, a generic filter widget named “filterable”, popups with arrows, tooltips for sliders and we integrated the tabs widget from jQuery UI.
See the changelog below for the key changes, and have a look at the jQuery Mobile 1.4.0 Beta 1 announcement to find out about all highlights of this new version of jQuery Mobile.

Demos | Key changes | Download & CDN

Read More  

Sunday, October 20, 2013

Difference between WHERE clause and HAVING clause

WHERE and HAVING both filters out records based on one or more conditions.

The difference is,

WHERE clause can only be applied on a static non-aggregated column whereas we will need to use HAVING for aggregated columns.

To understand this, consider this example. 

Suppose we want to see only those departments where department ID is greater than 3. There is no aggregation operation and the condition needs to be applied on a static field. We will use WHERE clause here:

SELECT * FROM DEPT WHERE ID > 3

Next, suppose we want to see only those Departments where Average salary is greater than 80. Here the condition is associated with a non-static aggregated information which is “average of salary”. We will need to use HAVING clause here:

SELECT dept.name DEPARTMENT, avg(emp.sal) AVG_SAL
FROM DEPT dept, EMPLOYEE emp
WHERE dept.id = emp.dept_id (+)
GROUP BY dept.name
HAVING AVG(emp.sal) > 80