CREATE PROCEDURE change_datetime AS
declare @id as int
declare @datetime as char(22)
declare #rep cursor for select [id],tempdate from table1
open #rep
fetch next from #rep into @id,@datetime
while @@fetch_status=0
begin
if isdate(@datetime) <> 1
begin
update table1 set tempdate=convert(datetime,'1900-01-01') where [id]=@id
end
fetch next from #rep into @id,@datetime
end
close #rep
deallocate #rep
GO