sql >> Database teknologi >  >> RDS >> Sqlserver

SQL Server svarende til Oracles CREATE OR REPLACE VIEW

Løsningerne ovenfor, selvom de vil få arbejdet gjort, gør det med risiko for at miste brugertilladelser. Jeg foretrækker at lave eller erstatte visninger eller lagrede procedurer som følger.

IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[vw_myView]'))
    EXEC sp_executesql N'CREATE VIEW [dbo].[vw_myView] AS SELECT ''This is a code stub which will be replaced by an Alter Statement'' as [code_stub]'
GO

ALTER VIEW [dbo].[vw_myView]
AS
SELECT 'This is a code which should be replaced by the real code for your view' as [real_code]
GO


  1. postgres kolonne X eksisterer ikke

  2. Installer MariaDB på en Mac

  3. Sådan nulstilles root-adgangskoden i MySQL 8.0

  4. kunde.pk_name joining transactions.fk_name vs. kunde.pk_id [serial] joining transactions.fk_id [heltal]