SQL生成规则数

--------------------------开始--------------------------
--开始值
DECLARE @start INT = 1
--结束值
DECLARE @end INT = 1000
--长度
DECLARE @length INT = LEN(@end)
--前缀
DECLARE @prefix VARCHAR(50) = ‘0990‘;
--后缀
DECLARE @suffix VARCHAR(50) = ‘‘;
------------------------------------------
WHILE @start < @end
    BEGIN
        INSERT  INTO dbo.Scenery
                ( Name
                )
        VALUES  ( @prefix + REPLICATE(‘0‘,
                                      @length
                                      - DATALENGTH(CAST(@start AS VARCHAR(50))))
                  + CAST(@start AS VARCHAR(50)) + @suffix
                )
        SET @start = @start + 1
    END
--------------------------结束--------------------------

SQL生成规则数,布布扣,bubuko.com

SQL生成规则数

上一篇:向Oracle数据库中CLOB插入数据报错问题


下一篇:txt文件导入mysql