Creating a SQL View with Linked Server and a view from Database A

I have database named Orders on Server named  PrimeServer.
I have a Linked Server object built (and working) on PrimeServer to a secondary server named OtherServer. The link shows the view I want named VW_MyOrders.

My goal is to build a view on my Orders database that links these 2 views together (the linked server view and the database view to create a new view)

I am trying to figure out can I do this visually or do I need to write it manually?

This is the view I have created on my Orders database:Other

SELECT     CONumber, OrderDate, Confirmed
FROM         dbo.VW_NewOrders

I want to link this view to a view on my Linked Server view named VW_MyOrders. My goal is to link the CONumber value on the 2 views but I usually work visually on SQL Views and cannot figure out how to get the 2 views linked together to give me live data.

This is the view from my Linked server:

SELECT [COCreatedDate]
  FROM [OtherServer].[OtherDatabase].[dbo].[VW_MyOrders]

How do I link the 2 servers and create a view in the PrimeServer in database named Orders?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kyle AbrahamsSenior .Net DeveloperCommented:
Try the following:
SELECT [COCreatedDate]
     , o2.OrderDate
  FROM [OtherServer].[OtherDatabase].[dbo].[VW_MyOrders] o1
 join VW_NewOrders  o2 on o1.[CONumber] = o2.[CoNumber]

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
allenkentAuthor Commented:
I can see the 2 views now connected. When I execute I get SQL EXECUTION ERROR.

Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_BIN" in the equal operation.

I confirmed my link value (CONumber are both VarChar(30).  Am I missing something?
Is it possible the CONumber's have different data types?

What about trying (referencing Kyle's code) ...
join VW_NewOrders  o2 on cast(o1.[CONumber] as int) = cast(o2.[CoNumber] as int)


join VW_NewOrders  o2 on cast(o1.[CONumber] as varchar(50)) = cast(o2.[CoNumber] as varchar(50))
Kyle AbrahamsSenior .Net DeveloperCommented:
That has to do with the collation on the tables themselves.

You can add a collation statement to each view so that everything is consistent.  (see section a)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.