In Progress

Help to write SQL Stored Procedure

I need help with a store procedure

I have 3 tables:

Customer table

-CustomerID varchar(50)

-ProductionDate datetime

-DiscontinuedDate datetime

-StopProductionDate datetime

-Portefolje_deactive int

tmtBB table

-CustID varchar

-SupplierID int

-StartDate datetime

-StopDate datetime

Vendor table

-id int

-vendorGUID uniqueidentifier

Relations:

[url removed, login to view] = [url removed, login to view]

[url removed, login to view] = [url removed, login to view]

[url removed, login to view] = @InputGUID

Requirements

(ProductionDate <= @InputDate and ProductionDate IS NOT NULL)

(StopProductionDate IS NULL or StopProductionDate >= @InputDate)

(DiscontinuedDate >= @InputDate or DiscontinuedDate IS NULL)

(Portefolje_deactive = 0)

The purpose of the stored procedure is to return the customers who is attached to a given vendor at a given time. You provide the stored procedure with and input date and inputguid (refers to a specific vendor through the vendor table) and it shall return the customer "belonging" to the giving vendor at that input date.

Some of the records has no StopDate because the StopDate is not known at the insert time.

There is 2 input parameters:

@inputGUID

@inputDate

Testdata:

customer table

CustomerID ProductionDate DiscontinuedDate StopProductionDate Portefolje_deactive

570714700000006500 2008-10-01 NULL NULL 0

tmtB table

CustID SupplierID StartDate StopDate

570714700000006500 1 1998-11-18

570714700000006500 1 2008-10-01 2009-03-01

570714700000006500 4 2010-08-01

570714700000006500 4 2010-12-01 2011-03-31

vendor table:

id vendorGUID

1 116A148C-8CF7-11E0-9FF8-FA8F4824019B

4 17429488-8CF7-11E0-9518-0A904824019B

@inputGUID = 116A148C-8CF7-11E0-9FF8-FA8F4824019B

@inputDate = 1998-11-17

Required result: Not return customer 570714700000006500 cause he is first attached to vendor 1 1998-11-18.

@inputGUID = 116A148C-8CF7-11E0-9FF8-FA8F4824019B

@inputDate = 1998-12-20

Required result: Return 570714700000006500 cause he is now attached to vendor 1 and will be until the next record with different vendoid.

@inputGUID = 116A148C-8CF7-11E0-9FF8-FA8F4824019B

@inputDate = 2010-10-10

Required result: Return 570714700000006500 due to record number 2.

@inputGUID = 116A148C-8CF7-11E0-9FF8-FA8F4824019B

@inputDate = 2010-08-01

Required result: Not return 570714700000006500 cause he is now attached to vendor 4.

@inputGUID = 17429488-8CF7-11E0-9518-0A904824019B

@inputDate = 2012-01-01

Required result: Return 570714700000006500 cause he is now attached to vendor 4. And inputGUID = vendor4's GUID.

@inputGUID = 116A148C-8CF7-11E0-9FF8-FA8F4824019B

@inputDate = 2012-01-01

Required result: Not return 570714700000006500 cause he is now attached to vendor 4. And inputGUID = vendor4's GUID.

For the simplicity I have only provided a single customer, but in the testing phase I will send more customers and tmtB records.

Skills: SQL

See more: need sql help, need a help to write a will, help to write, customer table, write sql , write s, stored, customer help, vendor store, sql different, sql required, datetime, insert sql, send help, sql int date, 2010 procedure, write requirements, write sql 2010, testing sql, testing phase, vedk, sql insert insert, testing purpose, help write, need null

About the Employer:
( 7 reviews ) Aarhus, Denmark

Project ID: #1203969

Awarded to:

eperfections

I am very good with databases specially procedure writing. I can write this procedure if you give me this opportunity.

$50 USD in 1 day
(71 Reviews)
5.9

19 freelancers are bidding on average $47 for this job

HussienSharaf

I can help Hussien Sharaf

$80 USD in 1 day
(13 Reviews)
6.4
sikandermandal

Please See PMB.

$30 USD in 1 day
(9 Reviews)
4.6
GediminasB

I am certificated .NET programmer working with .NET since 2002. My main specialization is WCF services, and database programming on MS SQL Server. I shal write you the procedure.

$50 USD in 1 day
(2 Reviews)
4.0
DeoTech

Hi! I have 11 years experience in MS SQL. If you have MS SQL or Access I can write procedure for you. Regards.

$50 USD in 1 day
(5 Reviews)
3.6
hcy0212

Let's start working on it!!

$50 USD in 1 day
(4 Reviews)
3.3
mukhan88

hi Please check your inbox :)

$50 USD in 0 days
(1 Review)
2.8
win4t4

I can work on this asap

$50 USD in 1 day
(1 Review)
1.8
nitookatyal

Hi, I've 5 years exp in writing complex Stored procedure and function in TSQl. I've seen your requiremnet and can deliver u the solution within 2-3 hours. Let me start. Thanks and Regards.

$70 USD in 1 day
(0 Reviews)
0.0
abbasmalik

I can develop the stored procedure for you. I have more than 18 year experience in enterprise software application development. I have higher education in IT and I am also microsoft certified solution developer.

$49 USD in 1 day
(0 Reviews)
0.0
Sumamcnaidu

Hi, I have about 3 years of experience in SQL queries and procedures. I will be able to do this as required. Thanks, Suma

$50 USD in 2 days
(0 Reviews)
0.0
rrmishra

Sql procedure will be provided as per given requirement

$40 USD in 3 days
(0 Reviews)
0.0
rajibalahsan

lets start.

$30 USD in 7 days
(0 Reviews)
0.0
ghharigovind

Hi, I am 3+ years experienced .Net developer. Now i am looking for freelance works. i could do you requirements easily, if you provide me the work. i have worked on many websites for my company. I can surely finish More

$30 USD in 1 day
(0 Reviews)
0.0
markoljpetrovic

ok, i can do it

$50 USD in 0 days
(0 Reviews)
0.0
robin587

good at writing better perfomance procedures

$35 USD in 1 day
(0 Reviews)
0.0
AhlyM

Hello Sir, I can do it in a couple of hours !! Thanks.

$50 USD in 0 days
(0 Reviews)
0.0
aqm163

Please view private message

$40 USD in 1 day
(0 Reviews)
0.0
mimoban

i can help you in this project..

$30 USD in 2 days
(0 Reviews)
0.0