I'm trying to figure out the syntax for creating a view (or function) but only if a dependent CLR assembly exits.
I've tried both
IF EXISTS (SELECT name FROM sys.assemblies WHERE name = 'MyCLRAssembly')
begin
create view dbo.MyView as select GETDATE() as C1
end
and
IF EXISTS (SELECT name FROM sys.assemblies WHERE name = 'MyCLRAssembly')
create view dbo.MyView as select GETDATE() as C1
go
Neither work. I get
Msg 156, Level 15, State 1, Line 2 Incorrect syntax near the keyword 'view'.
How can this be done?