Otis wrote:
Could you please try the attached DQE ? It's making an exception for SqlDbType.Date as it already did for SqlDbType.Time, which has the same issue: SqlParameter converts both to DateTime, instead of Date resp. Time.
I have copied DQE file to the server but it still builds the same query for me, not sure if this updated file should results the change to query string.
exec sp_executesql N'SELECT [MyDatabase].[dbo].[SQLDatesTable].[DateId], [MyDatabase].[dbo].[SQLDatesTable].[Date] FROM [MyDatabase].[dbo].[SQLDatesTable] WHERE ( ( [MyDatabase].[dbo].[SQLDatesTable].[Date] = @Date1))',N'@Date1 datetime',@Date1='2009-09-16 12:00:00'
It would results the record if it is either
exec sp_executesql N'SELECT [MyDatabase].[dbo].[SQLDatesTable].[DateId], [MyDatabase].[dbo].[SQLDatesTable].[Date] FROM [MyDatabase].[dbo].[SQLDatesTable] WHERE ( ( [MyDatabase].[dbo].[SQLDatesTable].[Date] = @Date1))',N'@Date1 [u]date[/u]',@Date1='2009-09-16 12:00:00'
or
exec sp_executesql N'SELECT [MyDatabase].[dbo].[SQLDatesTable].[DateId], [MyDatabase].[dbo].[SQLDatesTable].[Date] FROM [MyDatabase].[dbo].[SQLDatesTable] WHERE ( ( [MyDatabase].[dbo].[SQLDatesTable].[Date] = @Date1))',N'@Date1 datetime',@Date1='2009-09-16'
And here is create script of the table.
CREATE TABLE [dbo].[SQLDatesTable](
[DateId] [int] IDENTITY(1,1) NOT NULL,
[Date] [date] NOT NULL,
CONSTRAINT [PK_SQLDatesTable] PRIMARY KEY CLUSTERED
(
[DateId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]