• + 0 comments

    -----------------sql server--------------------- declare @x int; declare @y int; declare @z int; declare @count int; declare @output NVARCHAR(MAX) = ''; SET @z = 1000; SET @x = 2; SET @y = 2; SET @count = 0;

    while @x < 1000 begin while @y <= floor(sqrt(@x)) begin if @x % @y = 0 begin SET @count = @count + 1; break; end; SET @y = @y + 1; end; if @count = 0 begin SET @output = CONCAT(@output, CAST(@x as varchar), '&');

    end;
    SET @y = 2;
    SET @x = @x + 1 ;
    SET @count = 0;
    

    end;

    SET @output = LEFT(@output, LEN(@output) - 1); print @output;