MS SQL 2008 Recursive Query

I have an ASP.NET 4.0 application that uses an SQL 2008 database with a table called PERMIT. This Permit table has several fields but the fields of concern are

MCDNUM (FLOAT) (The permit number)

REPLACED (NVARCHAR) (Replaced this permit by another permit#)

OLD (NVARCHAR) (What the old permit number was before this one replaced it)

DATEISSUED (DATE) The date permit was issued

I prefer that you construct and test your own database rather than try to populate with my data. My data has under 5000 records but is sensitive.

The MCDNUM is a permit number. When the permit is renewed it is given a new number (A new record in the database) and then it REPLACED field gets entered this new MCDNUM. The new permit record gets the OLD the the MCDNUM from the "old" permit. It is possible that a permit is renewed and there are multiple new permits from it. When this happens the old permit number can only hold one number but the new MCDNUMS can have the same "OLD" MCDNUM So for example:



100 200

200 100

250 300

300 400 250

400 300

500 400

600 1000 400

700 400

1000 600

What i need is a query or mixture of a stored procedure that will allow me to enter an MCDNUM that will recursively look up ALL the associated record's MCDNUM and the DATEISSUED in the order of DATEISSUED

So if I were to search for MCDNUM 100 It would find 100 and 200

It has to search up and down in both the REPLACED and OLD fields and all of those records (REPLACED and OLD) fields. So if I searched 1000, I would get 600, 400, 300, 250

I think the results need to go into an array maybe? so that the same MCDNUMS are not duplicated as the final results will be a record set with the following:

MCDNUM, REPLACED, OLD, DATEISSUED order by the DateIssued field

I want error correction in case one of the fields is null or has an invalid data. Ultimately I will need the results of this query in a Gridview that will look at a URL parameter called MCDNUM which will plug in the search requirement number. So I am open to any suggestions or workflow.

Taidot: .NET, C# -ohjelmointi, SQL

Näytä lisää: what is recursively, what is recursive, think recursively, the final results, sql get date, recursively, get a parameter from url in asp net, recursive query, what is ms sql, recursive, query table, sql final, sql search asp, workflow 2013, sql maybe, asp sql search, gridview database, 2013 query, open recursive, sql test number, query query, 600 records, error correction asp, 100 600 700, mcdnum

Tietoa työnantajasta:
( 100 arvostelua ) United States

Projektin tunnus: #4263628

Myönnetty käyttäjälle:


Went through the requirements. Please view your PMB.

$30 USD 1 päivässä
(8 Arvostelua)

13 freelanceria on tarjonnut keskimäärin %project_bid_stats_avg_sub_26% %project_currencyDetails_sign_sub_27% tähän työhön


Please have a look at pm...

$120 USD 2 päivässä
(75 arvostelua)

Ready to start.

$50 USD 1 päivässä
(31 arvostelua)

hello, i'll be happy to create it in a day. regards, krishna

$50 USD 1 päivässä
(7 arvostelua)

Hello, We are ready for that job. Please check Private Message. Thanks & Regards Tera Technolabs

$80 USD 2 päivässä
(1 arvostelu)

.Net, SQL experts [url removed, login to view] see PM

$80 USD 5 päivässä
(1 arvostelu)

I work with software development since 1994, these years I have worked developing, coordinating and managing the development of applications: Client / Server, Web, embedded applications, bulk copy software, monitoring Lisää

$200 USD 2 päivässä
(0 arvostelua)

Hi there, I would like to express my interest to your ad post in [url removed, login to view] it be known that although that I have zero work hours here.I am hardworking and industrious. I will guarantee timely delivery of your p Lisää

$75 USD 1 päivässä
(0 arvostelua)

Hello, we have expert Microsoft certified SQL developers and DBA's that can create the query you are seeking with an incredible turnaround time.

$100 USD 1 päivässä
(0 arvostelua)

I am expert in SQL

$35 USD 4 päivässä
(0 arvostelua)

Ready to start.

$30 USD 1 päivässä
(0 arvostelua)

I am an developer working with ms sql server 2008 on a daily basis for almost 2 years already. I know exactly how this should be done. Please check pm.

$50 USD 2 päivässä
(0 arvostelua)

That's easy I think I can do it in record time of 24 hours.

$200 USD 5 päivässä
(0 arvostelua)