Posts

Showing posts from September, 2010

SQL SERVER – Simple Example of Recursive CTE

Recursive is the process in which the query executes itself. It is used to get results based on the output of base query. We can use CTE as Recursive CTE (Common Table Expression). You can read my previous articles about CTE by searching at http://search.SQLAuthority.com . Here, the result of CTE is repeatedly used to get the final resultset. The following example will explain in detail where I am using AdventureWorks database and try to find hierarchy of Managers and Employees. USE AdventureWorks GO WITH Emp_CTE AS ( SELECT EmployeeID, ContactID, LoginID, ManagerID, Title, BirthDate FROM HumanResources.Employee WHERE ManagerID IS NULL UNION ALL SELECT e.EmployeeID, e.ContactID, e.LoginID, e.ManagerID, e.Title, e.BirthDate FROM HumanResources.Employee e INNER JOIN Emp_CTE ecte ON ecte.EmployeeID = e.ManagerID ) SELECT * FROM Emp_CTE GO In the above example Emp_CTE is a Common Expression Table, the base record for the CTE is derived by the first sql query before UNION A

Using ASP.NET MVC 2 to Query Twitter's Public API - FIFA 2010

Using ASP.NET MVC 2 to Query Twitter's Public API - FIFA 2010 If you've been living under a rock for the last few years, you might not have heard of Twitter, but for the rest of us, it is a great communication tool. I have made countless friends with it including the authors of DotNetCurry! Thankfully Twitter has a public Application Programming Interface (API) which you can use and incorporate into your site, if you'd like to add Twitter feeds to it. This article demonstrates how to do it using ASP.NET MVC. To see this in action, I'm going to create a small ASP.NET MVC 2 website. If you haven't got Microsoft Visual Studio 2010, you can download the Express edition here. To begin with, let's take a look at the Twitter's API. The documentation is here, but for a brief overview, here's what you can do: - search - trends - trends/current - trends/daily - trends/weekly I'm going to be using the search API to search Twitter. Search returns twe