sql server - SQL : query large table -
i want query large data set in sql - right approach?
declare @datetime datetime select * sales salesdate <= @datetme
or:
select * sales salesdate < (select getdate())
or:
select * sales salesdate < getdate()
or using now()
all 3 have same execution plan other 0% assign stage variable in query no. 1. turn out practice in long run initialize variable datetime , use comparison. when have long comparisons make way, user habit of formatting datetime in variable , comparing column against variables. otherwise, becomes habit of formatting sql column , comapring date. formats datetime field in every data row comparison value , makes datetime comparisons slow.
for particular query, readability , ease of use, can select query no. 3 [select * sales salesdate < getdate()].
wiki
Comments
Post a Comment