遍历每个表进行指定操作
2007-05-31 10:36
218 查看
use websitedb
declare @tablename varchar(50)
declare @sqlstr varchar(300)
declare table_cursor cursor for
select o.name
from syscolumns c inner join sysobjects o on o.id=c.id
where o.xtype='u' and c.name='userid'
order by o.name
open table_cursor
fetch next from table_cursor into @tablename
while(@@fetch_status=0)
begin
set @sqlstr = 'select '''+@tablename+''' as tablename,* from '+@tablename+' where userid=''qifei'''
exec(@sqlstr)
fetch next from table_cursor into @tablename
end
close table_cursor
deallocate table_cursor
相关文章推荐
- 这是一个定时脚本,主要功能是遍历该文件夹下的所有文件并存储到数组,对数据中的文件进行操作,一个一个移动到指定的目录下,并删除原有文件
- 遍历指定文件夹,逐个打开每一个excel文件,进行操作
- 递归遍历PANEL,寻找PANEL内指定的控件进行操作
- 如何对memcache的数据(key-value)进行遍历操作
- hdu 3911 Black And White 一串0 1的数字 操作将一段区间[ i , j ]的每个数字进行异或操作 问区间最长0|1串
- Java对二叉搜索树进行插入、查找、遍历、最大值和最小值的操作
- [转载]如何对memcache的数据(key-value)进行遍历操作
- js实现检测当前时间是否超过指定时间,而进行操作
- 数组的创建/查找数组里面的内容/添加数组中元素/使用指定的字符串把数组链接起来/判断数组内是否有指定的数组元素/四种遍历进行输出数组中的元素有哪些
- Java中list如何利用遍历进行删除操作
- oracle 语句之对数据库的表名就行模糊查询,对查询结果进行遍历,依次获取每个表名结果中的每个字段(存储过程)
- 一张图像表示成NxN的矩阵,图像中每个像素是4个字节,写一个函数把图像旋转90度。 你能原地进行操作吗?(即不开辟额外的存储空间)
- Java对二叉搜索树进行插入、查找、遍历、最大值和最小值的操作
- java:File类中对文件或目录进行操作的常用方法以及遍历文件夹下面的文件
- 写一个方法进行各种属性的更新,而不要每个界面设置改变都改变一个属性。就是点击应用或确定按钮时调用这个更新属性的方法,遍历所有(控制对象属性的)界面控件的状态(值),进行属性修改和刷新。
- 如何对memcache的数据(key-value)进行遍历操作
- Qt文件操作:遍历文件夹中 指定格式的文件,并添加文件名到comboBox上
- c++对文件进行操作之遍历双层文件结构
- 利用System.IO中的Directory类对指定的目录进行遍历
- forin 遍历进行相关操作出现的错误以及解决方案