Hello,
New to the sql server need help with the below scenario.
Need help to get the table name from a sub query to the main query and also help me on selecting all the columns and records from the fetched table (i.e. table name fetched from the subquery)? Below is the sub query I have used.
select schema_name(t.schema_id) as schema_name,
t.name as table_name,
cast( REPLACE(t.name, 'storeId_', '') as int),
t.create_date,
t.modify_date
from sys.tables t
where t.name like 'storeId_2%' and
cast( REPLACE(t.name, 'storeId_', '') as int) =
(select MAX(cast(REPLACE(t.name, 'storeId_', '') as int))
from sys.tables t
where t.name like 'storeId_2%')
Thanks in Advance.