IF OBJECT_ID ('dbo.spSelectColValue_In_DB') IS NOT NULL
DROP PROCEDURE dbo.spSelectColValue_In_DB
go
create proc spSelectColValue_In_DB
AS
DECLARE @tableName varchar(50)
DECLARE My_Cursor CURSOR
FOR (select OBJECT_NAME(id) from syscolumns where id in(
select id from sysobjects where type='U')
and LOWER(name)='compid')
OPEN My_Cursor;
FETCH NEXT FROM My_Cursor INTO @tableName;
WHILE @@FETCH_STATUS = 0
BEGIN
declare @sql nvarchar(1000)
set @sql=' update '+@tableName +' set COMPID=(select top 1 id from Comp_Company) where COMPID is null'
print @sql
exec (@sql)
FETCH NEXT FROM My_Cursor INTO @tableName;
END
CLOSE My_Cursor;
DEALLOCATE My_Cursor;
GO
exec spSelectColValue_In_DB

GO

相关文章:

  • 2021-11-09
  • 2021-11-13
  • 2021-09-13
  • 2022-12-23
  • 2021-08-08
  • 2021-06-12
  • 2022-12-23
  • 2022-01-13
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-25
  • 2021-12-10
  • 2021-08-02
  • 2021-09-16
相关资源
相似解决方案