I mean, that using simple CREATE VIEW command it is not possible to create the VIEW in another database - just in the current one.
You can create table in another database using CREATE TABLE database.owner.tablename, but if you try to create VIEW by this way, you will get the error message 166: 'CREATE/ALTER VIEW' does not allow specifying the database name as a prefix to the object name.
And surely, the statement "Create view adventureworks.dbo.test as select * from sys.objects" wouldn't work - at least in MS SQL Server :)
But You can do it even so:
DECLARE @s nvarchar(1000)
SET @s = 'Create view dbo.test as select * from sys.objects'
EXEC adventureworks.dbo.sp_executesql @s
commented on Oct 9 2012 6:09AM