zoukankan      html  css  js  c++  java
  • 给包含compid列且值为null ,表的行数据赋值--


    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

  • 相关阅读:
    Hello World
    函数
    js基础
    html
    npm
    数据库
    前端了解的简要php
    模块
    scrapy爬虫
    php升级代码检查
  • 原文地址:https://www.cnblogs.com/markli/p/5132897.html
Copyright © 2011-2022 走看看