MS SQL 2008 Recursive Query

Closed

I have an [url removed, login to view] 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:

MCDNUM REPLACED OLD

---------------------------------------

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.

Skills: .NET, C# Programming, SQL

See more: 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

Project ID: #4263628

Awarded to:

wizziewizard

Went through the requirements. Please view your PMB.

$30 USD in 1 day
(8 Reviews)
4.5

13 freelancers are bidding on average $85 for this job

customizedata

Please have a look at pm...

$120 USD in 2 days
(75 Reviews)
5.5
cheapexcell

Ready to start.

$50 USD in 1 day
(31 Reviews)
4.4
krishnadubey

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

$50 USD in 1 day
(7 Reviews)
3.1
MitaBhuva

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

$80 USD in 2 days
(1 Review)
1.2
chetanchauhan87

.Net, SQL experts here.Please see PM

$80 USD in 5 days
(1 Review)
1.2
sergiogonzalez84

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

$200 USD in 5 days
(0 Reviews)
0.0
RayzInfotech2012

Hi there, I would like to express my interest to your ad post in Freelancer.Let 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 More

$75 USD in 1 day
(0 Reviews)
0.0
vw8066658vw

I am an asp.net(classic) 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 in 2 days
(0 Reviews)
0.0
celeronpm

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 in 1 day
(0 Reviews)
0.0
livioalves

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 More

$200 USD in 2 days
(0 Reviews)
0.0
yasminarafat

I am expert in SQL

$35 USD in 4 days
(0 Reviews)
0.0
urfreelance

Ready to start.

$30 USD in 1 day
(0 Reviews)
0.0