我会从information_schema.tables中选择并将结果保存到文件以构建表格列表,然后使用bat文件或命令行正则表达式工具将表格列表用作源代码来对照源代码中的文件进行比较目录。你可以输出什么文件有一个命中,什么表名被命中(如果你感兴趣的话,命中的是哪一行)。我不是一个grep高手,但我认为这将是正确的使用工具。
编辑 根据数据访问是如何处理的,你可能想扩大搜索列表使用finstr,游标包括INFORMATION_SCHEMA.ROUTINES
编辑2方法存储的特效,也许黑暗的一面
请注意,虽然下面应该工作,如果指向错误的目录,它可能会造成严重破坏。此外,只有源代码可从服务器访问并启用xp_cmdshell时,它才会起作用。也许整个想法是邪恶的,我不知道。
create table #files (filepath varchar(4000))
create table #tablesfound (tablename sysname, filepath varchar(4000))
declare @sql nvarchar(4000)
Declare @cmd nvarchar(400)
Declare @dir varchar(256)
Declare @tbl sysname
set @dir = 'source code directory with e.g. c:\source\'
declare crsX cursor for
Select table_name from information_schema.tables
open crsX
Fetch Next from crsX into @tbl
While (@@Fetch_Status = 0)
Begin
set @cmd = 'findstr /S /M ' + quotename(@tbl, char(34)) + ' ' + @dir + '*.*'
insert into #files exec xp_cmdshell @cmd
if exists (Select 1 from #files where filepath is not null)
Begin
insert into #tablesfound (tablename, filepath)
Select @tbl, filepath from #files where filepath is not null
delete from #files
End
print @cmd
Fetch Next from crsX into @tbl
End
close crsX
Deallocate crsX
Select * from #tablesfound
我喜欢它。我会尽力并接受你的答案,如果它解决了。 – JosephStyons 2009-01-23 14:51:27