-- Demonstration that a view retains
the old column names
-- after renaming a column, or adding
a column
CREATE TABLE Test1 (
ID int,
Name varchar(20)
)
INSERT INTO Test1
values (1, 'Hello')
INSERT INTO Test1
values (2, 'Good Bye')
SELECT *
FROM Test1
go
CREATE VIEW vTest1
AS
SELECT *
FROM Test1
go
SELECT *
FROM vTest1
EXEC sp_rename
'Test1.Name',
'NNName', 'COLUMN'
SELECT *
FROM Test1
SELECT *
FROM vTest1
alter table Test1
add MyNewCol varchar(20)
SELECT *
FROM Test1
SELECT *
FROM vTest1
DROP VIEW vTest1
DROP TABLE Test1
No comments:
Post a Comment