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.
Author |
Topic |
jmhc101
Starting Member
3 Posts |
Posted - 2013-01-18 : 08:34:01
|
hi, this query works:select ap.*from date_lookup d outer apply dbo.udf_ActivePlacementNumbersByDay(d.date_full) ap where d.date_full >= '20130101' and d.date_full <= '20130103'yet this one doesn't (it hangs):declare @startDate datedeclare @endDate date set @startDate = '20130101'set @endDate = '20130103' select ap.*from date_lookup d outer apply dbo.udf_ActivePlacementNumbersByDay(d.date_full) ap where d.date_full >= @startDate and d.date_full <= @endDateI'm assuming this must be a data type issue for the date variables. Can someone assist me in how I can pass a variable into this query and what data types to use correctly.If you need more context about the query - please let me know. |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-01-18 : 13:20:11
|
It could be because of a bad execution plan, or it could be because of the data types. Whether it is due to data types is easy to check change your WHERE clause to:where d.date_full >= CAST(@startDate as DATE)and CAST(d.date_full <= @endDate as DATE) |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
|
|
|
|