views:

14

answers:

1

I have a server which I need to have as a linked server to another server, using sp_addLinkedServer.

My server's name is in the format "DepartmentName.CompanyName.com", which I can usually change to [blah.blah.com], but which I can't use in the SQL Server Management Studio View creator, because it keeps deleting my square brackets...

On the other hand, because the @srvproduct is SQL Server, I can't specify a name for the server to use, either, so I can't just call it "DepartmentName".

I seem to be in a bit of a catch-22 here. Any suggestions?

+1  A: 

The View editor in Management studio (and enterprise manager before it) is, shall we say, rather limited, and prone to exploding the number of references to a table/view if there are complex conditions.

It's much to be preferred that you learn to write CREATE/ALTER VIEW statements in query windows (there are options to script VIEWs to a new query window as ALTER, if you're wanting to update an existing view).

Alternatively, you can add the linked server using, say, the "Microsoft OLE DB Provider for SQL Server", "SQL Native Server", or any of a number of other providers, rather than using the "SQL Server" provider, and then you can specify a different name for the linked server. (We do this in my shop so that our test servers refer to their partners using the same names as are used on our production servers)

E.g.:

EXEC master.dbo.sp_addlinkedserver @server = N'ALIAS', @srvproduct=N'ACTUALSERVER', @provider=N'SQLOLEDB', @datasrc=N'ACTUALSERVER'
Damien_The_Unbeliever
In a programming situation where precise-ness is such a key part of what we do, I do love when the answer is "Yeah, just lie to the computer about what you're doing and it'll stop bugging you about it." No sarcasm intended, here, I just love the irony of it.
Frosty840
@Frosty840 - and yet you're happy to rely on the imprecision of the view designer (which is causing your main problem), rather than writing SQL directly :-|
Damien_The_Unbeliever
Oh, I'm not happy about any of it. The difference is, I'm writing the linked server bit. Some other eedjit used the View Designer.
Frosty840