February 17, 2018 at 1:13 pm
I would like to create a view in a database that gets data from another database. Here is beginning of statement:
create view data_01..EDISent as
USE edi_01
GO
......
The USE statement is underlined in red. Can i not have a USE statement inside a create view statement?
February 17, 2018 at 1:31 pm
Why not just use a the 3-part naming convention when creating your view?
USE Tempdb;
GO
CREATE VIEW MyView
AS
SELECT CustomerID
FROM Galactic.dbo.Customer;
I'm creating a view inside one database (tempdb) that gets data from another database (Galactic).
February 17, 2018 at 1:35 pm
pietlinden - Saturday, February 17, 2018 1:31 PMWhy not just use a the 3-part naming convention when creating your view?
USE Tempdb;
GO
CREATE VIEW MyView
AS
SELECT CustomerID
FROM Galactic.dbo.Customer;
You're right. USE is not allowed in views or stored procedures apparently. Thanks.
March 1, 2018 at 12:11 pm
Jackie Lowery - Saturday, February 17, 2018 1:35 PMpietlinden - Saturday, February 17, 2018 1:31 PMWhy not just use a the 3-part naming convention when creating your view?
USE Tempdb;
GO
CREATE VIEW MyView
AS
SELECT CustomerID
FROM Galactic.dbo.Customer;You're right. USE is not allowed in views or stored procedures apparently. Thanks.
That's because the USE statement isn't a query element, it's a batch directive, similar to GO in that respect.
Steve (aka sgmunson) 🙂 🙂 🙂
Rent Servers for Income (picks and shovels strategy)
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply