有,从系统表里找,在syscolumns里有所有的字段,以及其对应的表id。最好用存储过程来写。
解决方案 »
- 哪里能下载到Delphi4.0?
- 原来使用了TUpdateSQL 现在用了ADO 请问 这个控件用什么办法替代
- 环思的erp软件界面
- 谁看得懂下面的代码?能解释清楚的,可以再加100分!
- access与sql server的数据类型! 急
- 为什么安装了DevExpress.ExpressQuantumGrid.Suite.v5.0.FS却找不到dxDBGrid控件?
- 谁有imgedit.ocx控件,必须支持winXP,或有类似控件,必有答谢! [email protected]
- Numeric数据类型的显示问题?
- 网路管理+串口通讯,请提供思路或例子
- 关于webservice返回值与http头的问题
- 在bcb没人理会的问题,在delphi论坛碰碰运气
- MSSQL,可以连接多少个客户进行正常工作?
进一步可得到字段名,再进行查找。
syscolumns 中存放着字段名
试试吧
SQL SERVER本身维护了几个系统视图,反映了这些情况。先找到有那些表,然后建立一个游标,在游标中对每个表定义一个SQL语句,动态执行,返回符合你条件的表明。
应该不是很难,希望你能解决!
name varchar(200)
)declare @name varchar(200)
declare @i int
declare cur scroll cursor for select name from sysobjects where id in (select id from syscolumns where name = 'name')open cur
fetch first from cur into @name
set @i=0
while @i<@@cursor_rows
begin
execute('insert into #TableList select '''+@name+''' from '+@name+' where name=''李四''')
fetch next from cur into @name
set @i = @i+1
end
close cur
deallocate curselect * from #TableList
你的要求的确很怪,如果你的数据库大点...
create table #TableList(
name char(200),
)declare @name varchar(200)
declare @col varchar(200)
declare @sWhere varchar(1000)
declare @i int
declare @j int
declare @iMax int
declare @jMax intdeclare curTab scroll cursor for select name from sysobjects where xtype='u'
select @iMax=count(*) from sysobjects where xtype='u'open curTab
fetch first from curTab into @name
set @i=1
while @i<@iMax
begin
select @jMax=count(*) from syscolumns where (xtype=175 or xtype=167) and (id in (select id from sysobjects where name=@name))
if @jMax=0
begin
set @i=@i+1
continue
end
declare curCol scroll cursor for select name from syscolumns where (xtype=175 or xtype=167) and (id in (select id from sysobjects where name=@name))
open curCol
fetch first from curCol into @col
set @sWhere=' where '+@col+'=''李四'''
set @j=2
while @j<@jMax
begin
fetch next from curCol into @col
set @sWhere=@sWhere+' or '+@col+'=''李四'''
set @j=@j+1
end;
close curCol
deallocate curCol
execute('insert into #TableList select '''+@name+''' from '+@name+@sWhere)
fetch next from curTab into @name
set @i = @i+1
end
close curTab
deallocate curTabselect * from #TableList
note:
only used by CHAR or VARCHAR field