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)