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 2000 Forums
 Transact-SQL (2000)
 stored procedure with optional datetime parameter

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-02-27 : 12:06:26
Marichelle writes "Hi there,

I have a stored procedure where there's 6 optional parameters. 5 of these are strings so i can easily default these to %. The one I'm having a hard time with is the datetime parameter. How do I handle this? Thanks so much.

Here is my non-working code =( :

CREATE PROCEDURE TimeAnalysis
(
@company_name varchar(50) = "%",
@employee_name varchar(50)= "%",
@work_no varchar(50)= "%",
@work_type varchar(50)= "%",
@time_type varchar(50)= "%",
@work_date datetime = '01/01/1900'
)

AS
SELECT * from employee_timesheet
WHERE company_name LIKE @company_name AND employee_name LIKE @employee_name
AND work_no LIKE @work_no AND work_type LIKE @work_type AND time_type LIKE @time_type AND (work_date = '01/01/1900 OR work_date = @work_date) "

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-02-27 : 12:27:27
Do not double or cross post.

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=62434

CODO ERGO SUM
Go to Top of Page
   

- Advertisement -