如何在数据库中以一些字符串结尾搜索所有表名,并在返回的表上检查一些值?

发布于 2025-01-23 23:43:19 字数 577 浏览 4 评论 0原文

我有一个数据库,该数据库有很多表,我想做的是以“ validation”结尾的所有表检索我能够返回这些表柱子。 有人可以帮我吗?

ALTER PROCEDURE [dbo].[sp_validateWinner]
 AS
 BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

Declare @querytable nvarchar(max)
set @querytable='SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES 
WHERE TABLE_NAME LIKE ''%Validate%'''

Execute sp_executesql @querytable
END

这是返回所有表的过程,但我还想检查该表上的值

select C0R0,C2R0 from Table_Name_ending_with_Validate where(C0R0=1 and C2R0 =22)

I have a database which has many tables What i want to do is retrive all the tables ending with a string "Validate" I am able to return those tables but, how can i query on those returned tables to check for a specific value in a column.
Can anyone please help me?

ALTER PROCEDURE [dbo].[sp_validateWinner]
 AS
 BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

Declare @querytable nvarchar(max)
set @querytable='SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES 
WHERE TABLE_NAME LIKE ''%Validate%'''

Execute sp_executesql @querytable
END

This is the procedure that returns all the table but i further want to check for values on this table which is something like

select C0R0,C2R0 from Table_Name_ending_with_Validate where(C0R0=1 and C2R0 =22)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文