drop procedure up_AddCol4Obbr
go
@strTable nvarchar(100),
@strColName nvarchar(100),
@strType nvarchar(100)
as
begin
declare @strSQL nvarchar(1000)
begin
select @strSQL = N'alter table ' + @strTable + ' add ' + @strColName + ' ' + @strType
end
else
begin
select @strSQL = N'alter table ' + @strTable + ' alter column ' + @strColName + ' ' + @strType
end
end
go
drop procedure up_CheckCols4Obbr
go
as
begin
declare @nColCnts smallint, @nShopCnts smallint, @nCol smallint, @nShop smallint
declare @strColName nvarchar(30), @strType nvarchar(50), @strTable nvarchar(50)
select @nShopCnts = count(*) from u_obbs
select @nCol=1, @nShop=1, @strTable='U_OBBR'
begin
select @strColName = 'TC' + right('00'+cast(@nCol as nvarchar(10)),2)
select @strType = dType from joyouext.dbo.u_obbc where colId = @nCol
end
begin
set @nCol=1
while @nCol<=@nColCnts
begin
select @strColName = 'BC' + right('00'+cast(@nShop as nvarchar(10)),2) + right('00'+cast(@nCol as nvarchar(10)),2)
select @strType = dType from joyouext.dbo.u_obbc where colId = @nCol
exec up_AddCol4Obbr @strTable, @strColName, @strType
select @nCol = @nCol + 1
end
end
end
go