declare @query varchar(max)
set @query = 'select '' select * from '' + Table_Name + '' where '' + Column_Name + '' = 1337 '''
set @query = @query + ' from INFORMATION_SCHEMA.COLUMNS where Column_Name like ''%_ID%'''
exec (@query)
--Produces :
--select * from TABLE1 where Table1_ID = 1337
--select * from TABLE42 where Table42_ID = 1337
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.