Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing data into SP from DDL 1

Status
Not open for further replies.

zzzzzeke

Programmer
Mar 1, 2004
14
US
do i have to use parameters to pass data into a SP?

i'm trying to take a date value from a drop down list and running a query based on that date.
 
>> May 27, 2004
do i have to use parameters to pass data into a SP?

The SP will receive the data as a parameter.

You can pass it as a datetime parameter or as a character parameter or as part of the exec string - if so use yyyymmdd format.


======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
 
Show shipped sales within the past (DDL otpions: 1 7 30 60 90 180 All) days

how will i go about the SQL statement?

SELECT *
FROM orders
WHERE (shipping_status = 'shipped')

shipped_date is what i'm wanting to compare against.....


so will i have to get todays date, and -180 if 180 days is selected from the DDL?
 
create proc GetResult
@NoDays int
as

SELECT *
FROM orders
WHERE shipping_status = 'shipped'
AND ( shipping_Date >= convert(varchar(8),dateadd(dd,@NoDays * -1, getdate()),112)
or @NoDays is null
)
go




======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
 
Thanks nigelrivett, but I ended up using the DATEDIFF function.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top