Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update query

Status
Not open for further replies.
Apr 14, 2004
22
US
Hi,

This update query very slow to do a update, 12 gigabyte databse, sql server 2000, windows server 2003.


UPDATE CallStat.dbo.RUN
SET Service_RUN = ''' + @Good +
''' WHERE Transaction_ID = ' + @Bad +
' AND Date_RUN BETWEEN convert(DATETIME, ''' + @Date1 + @vsTime + ''') AND convert(DATETIME, ''' + @Date2 + @veTime + ''')' )
 
Why do you have all the single quotes in there. They aren't needed.
Code:
declare @StartDate datetime
declare @EndDate datetime
set @StartDate = convert(datetime, @Date1 + ' ' + @vsTime)
set @EndDate = convert(datetime, @Date2 + ' ' + @veTime)

update CallStat.dbo.RUN
set Service_Run = @Good
WHERE Transaction_ID = @Bad
   and Date_RUN BETWEEN @StartDate and @EndDate
What columns on your table has indexes and are they clustered or non-clustered?

Denny
MCSA (2003) / MCDBA (SQL 2000) / MCTS (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 


Individual Index fields are Service_Run, Transaction_ID, Date_RUN
No clustered index
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top