DECLARE @locno VARCHAR(50); -- 声明 locno 字段，指定长度
DECLARE @locsts NVARCHAR(50);
DECLARE @row1 INT = 27;
DECLARE @bay1 INT = 19;
DECLARE @lev1 INT = 1;
DECLARE @fullplt VARCHAR(1); -- 假设 fullplt 只需要一个字符
DECLARE @loctype1 INT = 6;
DECLARE @ft DATETIME;
DECLARE @mt DATETIME;
DECLARE @apt DATETIME;
DECLARE @et DATETIME;
DECLARE @stas INT;
DECLARE @floor INT;
DECLARE @maprow INT = 21;
DECLARE @mapbay INT = 19;
DECLARE @rightside INT = 0;
DECLARE @plttype INT = 777;



-- 使用 WHILE 循环来控制 row1 的范围
WHILE @row1 <= 38
BEGIN
	-- 在每次循环中，更新 lev1 的值
	SET @bay1 = 19; -- 重置 lev1
	SET @mapbay = 19; -- 重置 lev1

	WHILE @bay1 <= 33
	BEGIN
		-- 生成 locno 和其他字段的值
		SET @locno = 'YZ_0' + CAST(@row1 AS VARCHAR(2)) + '_0' + RIGHT('00' + CAST(@bay1 AS VARCHAR(2)), 2) + '_0' + CAST(@lev1 AS VARCHAR(2)) + 'F2';
		SET @locsts = 'O';
		SET @fullplt = 'N';
		SET @ft = GETDATE();
		SET @mt = GETDATE();
		SET @apt = GETDATE();
		SET @et = GETDATE();
		SET @stas = 0;
		SET @floor = 2;

		-- 插入数据
		INSERT INTO agv_loc_mast (loc_no, plt_type,loc_sts, row1, bay1, lev1, full_plt,loc_type1, first_time, modi_time, appe_time, error_time, status, floor,map_row1,map_bay1,right_side)
		VALUES (@locno, @plttype, @locsts, @row1, @bay1, @lev1, @fullplt,@loctype1, @ft, @mt, @apt, @et, @stas, @floor,@maprow,@mapbay,@rightside);

		-- 更新 lev1
		SET @bay1 = @bay1 + 1;
		SET @mapbay = @mapbay + 1;
	END

	-- 更新 row1
	SET @row1 = @row1 + 1;
	SET @maprow = @maprow + 1;
END