[dba-Tech] SQL Question

Paul Hartland paul.hartland at googlemail.com
Mon Jul 16 06:05:28 CDT 2018


Its quite bad coding really, it means to just create sn inifinite loop, so
I would imagine there may be another condition statement inside the begin
and end which tells the system to break the loop  but still bad coding
practice in my opinion

Paul

On Mon, 16 Jul 2018, 11:55 Martin Reid, <mwp.reid at qub.ac.uk> wrote:

> We are running a script to delete a few million records from a CRM SQL
> Server. This bit is confusing us "While 1 =1" . We can't understand how
> this would ever evaluate to anything other than 1 =1?
>
> IF EXISTS (SELECT name from sys.indexes
> WHERE name = N'CRM_AsyncOperation_CleanupCompleted')
>       DROP Index AsyncOperationBase.CRM_AsyncOperation_CleanupCompleted
> GO
> CREATE NONCLUSTERED INDEX CRM_AsyncOperation_CleanupCompleted
> ON [dbo].[AsyncOperationBase] ([StatusCode],[StateCode],[OperationType])
> GO
>
> while(1=1)
> begin
>
> We also ran the full script for 34 hours and it ran successfully but turns
> out left 22million records undeleted all of which meet the deletion
> criteria!
>
> It's a Microsoft script. Confusing.
>
> Martin
>
>
> _______________________________________________
> dba-Tech mailing list
> dba-Tech at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-tech
> Website: http://www.databaseadvisors.com
>


More information about the dba-Tech mailing list