如何在数据库中以一些字符串结尾搜索所有表名,并在返回的表上检查一些值?
我有一个数据库,该数据库有很多表,我想做的是以“ 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论