I have a requirement to create views on all tables in a database. Yes, I know-dumb request, but I enjoy eating and living in a house. Would one of you assist me in creating a SQL script that would do this? The query below that returns a list of Schema, Table, Column and Ordinal Position in the database. And it needs to test to see if it exists and if so drops the view and then create the new view.
SELECT TOP 100 PERCENT sc.table_schema
from information_schema.columns sc INNER JOIN
sys.tables AS t ON sc.table_name = t.name INNER JOIN
sys.columns AS c ON c.object_id = t.object_id AND c.name = sc.Column_Name
order by table_schema, table_name, ordinal_position
order by TABLE_SCHEMA