sql query

I have c# aspx.net with ms SQL server and have one question about SQL

assume I have a web form and come with start date and end date. the format is 20181201 and 20181231 and they are an integer.
and I have to run a SQL statement like below.

select top 1 * from transacation_history where deposit_date >= 20181201 and deposit <= 20181231
Or
I should use between statement? but I do not know how to do that.
1. Which one run faster?
2. I will convert it into stored procedure. In this logic, is it best practice in ms sql?

Thanks.
LVL 1
ITsolutionWizardAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lcohanDatabase AnalystCommented:
Are there truly two different columns in the above statement? Or rather the same column and it was just typo?
Assuming is just typo if you check the query plans for the two statements below you may see that actually between is converted to GTE/LTE

select top 1 * from transacation_history where deposit_date >= 20181201 and deposit_date <= 20181231;
select top 1 * from transacation_history where deposit_date  between 20181201 and 20181231;


Just make sure index exists on the deposit_date
Scott PletcherSenior DBACommented:
1) BETWEEN will be converted to >= and <=, so there will be no performance difference between them.
2) Yes, that is standard best practice in SQL Server.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ITsolutionWizardAuthor Commented:
just typo sorry.
I have one column in the table
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.