Home > Database > Mysql Tutorial > body text

使用存储过程 修改符合条件的数据表的相关字段 的数据类型

WBOY
Release: 2016-06-07 17:37:16
Original
1155 people have browsed it

使用存储过程 修改符合条件的数据表的相关字段 的数据类型 处理思路: 查询系统表 获得符合条件的数据表 及 其列名 和 大小 通过循环 执行动态SQL语句 实现Column Type 的改变 本次示例效果: 将Product_开头的数据表中,varchar类型的Column类型 修改为nvar

使用存储过程 修改符合条件的数据表的相关字段 的数据类型

处理思路:

查询系统表 获得符合条件的数据表 及 其列名 和 大小

通过循环 执行动态SQL语句

实现Column Type 的改变

 

本次示例效果:

将Product_开头的数据表中,,varchar类型的Column类型 修改为nvarchar

 

 

代码如下:

dbo.sysobjects ) ) = 1) drop procedure spChangeProductTableVarcharColumnToNvarchar GO /* exec spChangeProductTableVarcharColumnToNvarchar dbo.spChangeProductTableVarcharColumnToNvarchar (100) (100) (100) (200) local for select T.NAME as tabName , C.NAME as colName ,) as colLength FROM syscolumns C left join sysobjects T on C.id = T.id T.NAME C.xusertype ) ,) , (@SQL_CHANGE_COLUMN_TYPE) ,

 

posted on

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!