CREATE PROCEDURE [dbo].[UpdateColumnValue]
@tableName as varchar(100),
@copyFromColumnName as varchar(100),
@copyToColumnName as varchar(100)
AS
BEGIN
DECLARE @query as varchar(max);
SET @query = ' UPDATE ' + @tableName +
' SET ' + @copyToColumnName + ' = ' + @copyFromColumnName +
' WHERE ' + @copyToColumnName + ' IS NULL';
EXECUTE(@query);
END
2条答案
按热度按时间bq9c1y661#
创建一个如下所示的存储过程,并将表名、主键列名和copy to列名传递给它。它将创建查询并执行。
ss2ws0br2#
您可以添加
Foreign Key
对同一表格的引用:通过使用
UPDATE
声明: