In solving one of the tasks (рассчет автокредита) I needed an opportunity to perform stored procedure of SQL Server 2005, to receive data from the FireBird database.
Typically stored procedure in T-SQL can not do this, so I wrote a stored procedure in C#, which receives the necessary data to the DataTable(s), from where then method SqlContext.Pipe.SendResultsRow, passing a string SQL Server.
Here is the example:
Showing posts with label SQL Server. Show all posts
Showing posts with label SQL Server. Show all posts
Wednesday, July 29, 2009
Tuesday, April 28, 2009
How to sort the hierarchical recursive query in SQL Server 2005
In SQL Server 2005 was an innovation in the form of CTE (common table expressions), which enables the hierarchical recursive queries to the database. While designing the web site автокредит на автомобиль I have a challenge: to display the hierarchical structure of pages of the site. The query also have to sort sort the data on a field "pageorder" from the pages with the same level of hierarchy.
The structure of the table looks like this:
The field "pid" points to id of the parent record. In addition, there have to exist a root(entry) record, whose pid = NULL.
Below is a sample request that selects and sorts the hierarchical data:
The structure of the table looks like this:
CREATE TABLE [dbo].[pages](
[id] [int] NULL,
[pid] [int] NULL,
[title] [nvarchar](max) NULL,
[pageorder] [int] NULL
) ON [PRIMARY]
The field "pid" points to id of the parent record. In addition, there have to exist a root(entry) record, whose pid = NULL.
Below is a sample request that selects and sorts the hierarchical data:
Subscribe to:
Posts (Atom)
