Click here to Skip to main content
15,902,189 members
Home / Discussions / Database
   

Database

 
GeneralRe: ignore last one, this is the tsql puzzle Pin
partt2-Aug-04 11:22
partt2-Aug-04 11:22 
GeneralRe: ignore last one, this is the tsql puzzle Pin
Steven Campbell2-Aug-04 14:30
Steven Campbell2-Aug-04 14:30 
GeneralRe: ignore last one, this is the tsql puzzle Pin
partt3-Aug-04 4:00
partt3-Aug-04 4:00 
GeneralRe: ignore last one, this is the tsql puzzle Pin
partt3-Aug-04 5:13
partt3-Aug-04 5:13 
GeneralRe: ignore last one, this is the tsql puzzle Pin
Manu T8-Aug-04 20:53
sussManu T8-Aug-04 20:53 
Generaltsql query puzzle Pin
partt2-Aug-04 8:38
partt2-Aug-04 8:38 
GeneralRe: tsql query puzzle Pin
andyharman4-Aug-04 23:47
professionalandyharman4-Aug-04 23:47 
GeneralData Dictionary Pin
Britnt72-Aug-04 3:08
Britnt72-Aug-04 3:08 
Generallooping datatable Pin
robmays1-Aug-04 23:23
robmays1-Aug-04 23:23 
GeneralRe: looping datatable Pin
Steven Campbell2-Aug-04 14:32
Steven Campbell2-Aug-04 14:32 
GeneralRe: looping datatable Pin
robmays2-Aug-04 20:56
robmays2-Aug-04 20:56 
GeneralCollation name question... Pin
theJazzyBrain1-Aug-04 6:54
theJazzyBrain1-Aug-04 6:54 
GeneralRe: Collation name question... Pin
Thea Burger2-Aug-04 1:11
Thea Burger2-Aug-04 1:11 
QuestionDetecting overlapping date ranges - best strategy - help? Pin
Paul Evans1-Aug-04 5:38
Paul Evans1-Aug-04 5:38 
Generalhai Pin
Asha Rams31-Jul-04 22:32
Asha Rams31-Jul-04 22:32 
GeneralBTrieve 6.15 Pin
Mega131-Jul-04 18:05
Mega131-Jul-04 18:05 
GeneralRe: BTrieve 6.15 Pin
Mekong River1-Aug-04 4:07
Mekong River1-Aug-04 4:07 
GeneralSynchronizing tables Pin
winpiglet31-Jul-04 10:43
winpiglet31-Jul-04 10:43 
Questionis there any Win32 function help access SQL server? Pin
fu031-Jul-04 1:47
fu031-Jul-04 1:47 
AnswerRe: is there any Win32 function help access SQL server? Pin
Michael P Butler31-Jul-04 22:14
Michael P Butler31-Jul-04 22:14 
GeneralSP - Efficient "Find" method Pin
UB30-Jul-04 21:58
UB30-Jul-04 21:58 
GeneralRe: SP - Efficient "Find" method Pin
Daniel Turini31-Jul-04 11:05
Daniel Turini31-Jul-04 11:05 
As a general rule, don't use functions or the LIKE operator on your table columns or your query won't use any indexes.
The easiest way of speeding this query is by replacing this (I assume there's a typo and there is no '@' outside the COALESCE):

WHERE  empid LIKE COALESCE(CONVERT(varchar(3), @empid), '%')
AND    batchid LIKE COALESCE(CONVERT(varchar(3), @batchid), '%')


for something like this:
WHERE  empid BETWEEN @firstEmpid AND @lastEmpid 
AND    batchid  BETWEEN @firstBatchid AND @lastBatchid 

And do a bit of math to calculate the first and last ids.
If this filter returns a small result set, then the slowest part (show below) of the query won't need to run against a lot of records and the query will be way faster.

AND    name LIKE ('%' + @name + '%'




Yes, even I am blogging now!
GeneralSQL query to generate random numbers Pin
Imtiaz Murtaza29-Jul-04 23:45
Imtiaz Murtaza29-Jul-04 23:45 
GeneralRe: SQL query to generate random numbers Pin
Steven Campbell30-Jul-04 7:55
Steven Campbell30-Jul-04 7:55 
GeneralRe: SQL query to generate random numbers Pin
Grimolfr30-Jul-04 8:22
Grimolfr30-Jul-04 8:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.