Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 i have 2 tables how to get data if...

Author  Topic 

asifbhura
Posting Yak Master

165 Posts

Posted - 2010-10-04 : 12:05:14
Hi,
I have two tables
1.Application
column in application are like,
applicationNo,userno,Offerno,Email,Mobile,department

2.Offer
Columns in offer are offerno,startdate,enddate,offertype,offerdesc

Now,I want all application
WHERE offer'startdate is greater than current date and Application's userno='1'

Regards,
ASIF

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-10-04 : 12:22:02
can we see what you tried till now?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

asifbhura
Posting Yak Master

165 Posts

Posted - 2010-10-04 : 12:47:15
ALTER PROCEDURE ERS_SP_GetAvailableApplicationByapplicant
-- Add the parameters for the stored procedure here
@ApplicantID nvarchar(50),
@CurrentDate nvarchar(15)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here

SELECT * FROM
Application a
INNER JOIN Offer o
ON a.OfferNo=o.OfferNo
WHERE a.ApplicantNo='1'
AND o.SubmissionStartDate >=@CurrentDate
Go to Top of Page

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-10-04 : 14:14:03
quote:
Originally posted by asifbhura

ALTER PROCEDURE ERS_SP_GetAvailableApplicationByapplicant
-- Add the parameters for the stored procedure here
@ApplicantID nvarchar(50),
@CurrentDate nvarchar(15) --Why don't you take it datetime or date datatype
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here

SELECT * FROM
Application a
INNER JOIN Offer o
ON a.OfferNo=o.OfferNo
WHERE a.ApplicantNo='1'
AND o.SubmissionStartDate >=@CurrentDate --If the values are stored as varchar then conversion may be required.Let us know the datatype of SubmissionStartDate

Go to Top of Page

asifbhura
Posting Yak Master

165 Posts

Posted - 2010-10-04 : 14:28:26
SubmissionStartDate is also nvarchar

i have taken because we save date in arabic

as number like '14311212'

and parameter value will be also in same format

regards
Go to Top of Page
   

- Advertisement -