clear markdown compare help donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 462285 distinct fiddles created so far.

CREATE TABLE dbo.t1(c1 int, c2 int); INSERT dbo.t1(c1,c2) VALUES(1,2);
1 rows affected
 hidden batch(es)


CREATE VIEW dbo.v_t1 AS SELECT * FROM dbo.t1;
 hidden batch(es)


-- qué pasa si hacemos cambios a la tabla? EXEC sys.sp_rename N'dbo.t1.c2', N'c3', N'COLUMN'; ALTER TABLE dbo.t1 ADD c2 date NOT NULL DEFAULT GETDATE(); ALTER TABLE dbo.t1 ADD c4 uniqueidentifier NOT NULL DEFAULT NEWID();
Caution: Changing any part of an object name could break scripts and stored procedures.
 hidden batch(es)


-- la vista muestra data incorrecta SELECT * FROM dbo.t1; SELECT * FROM dbo.v_t1;
c1 c3 c2 c4
1 2 16/03/2018 00:00:00 b56fd8c3-6314-4fe3-995f-f1991611261b
c1 c2
1 2
 hidden batch(es)


EXEC sys.sp_refreshview @viewname = N'dbo.v_t1';
 hidden batch(es)


SELECT * FROM dbo.v_t1;
c1 c3 c2 c4
1 2 16/03/2018 00:00:00 b56fd8c3-6314-4fe3-995f-f1991611261b
 hidden batch(es)