May 13, 2013 at 5:46 am
can't help that much yet;
you didn't mention any specific error you get back, and it might be nice to see the actual command you are using in sqlcmd to create the view;
Lowell
May 13, 2013 at 6:32 am
also, to create a view on Server 2, FROMserver 1, you need to do one of two things:
either the SQLcmd needs to actually connect to server 2, and not server 1
--sqlcmd -H<Host name if on different machine> -S<SQL server name\instance name> -U<username if needed> -P<password> -E -i<input file for execution> -o<output file for results>
sqlcmd -HServer2 -S<SQL server name\instance name> -U<username if needed> -P<password> -E -i<input file for execution> -o<output file for results>
or
you need to use a command featuring EXECUTE AT on server 1
example:
EXEC sp_addlinkedserver 'SeattleSales', 'SQL Server'
GO
EXECUTE ( 'CREATE TABLE AdventureWorks2008R2.dbo.SalesTbl
(SalesID int, SalesName varchar(10)) ; ' ) AT SeattleSales;
Lowell
May 13, 2013 at 6:45 am
Hi,
Thanks for the response and apologies about the vagueness. I'll try to be a bit more specific.
The SQLCmd is getting the sql from a networked file using:
sqlcmd -S [Server2] -d [DBName] -b -i "\\NetworkScriptLoc\testview.sql"
The testview.sql just contains
If not exist...
Create view as
Select c2, etc from Server1.DbName.dbo.TableName
and the error is the old favourite - "Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. Reason: Token-based server access validation failed with an infrastructure error. Check for previous errors". However, other scripts creating other objects work even when this fails and they are all using the same technique and service account. The only difference is that the view has a reference back to the server initiating the request.
SQL DBA
Every day is a school day, and don't trust anyone who tells you any different.
http://sqlblogness.blogspot.co.uk
May 13, 2013 at 9:23 am
Looks like you are running into the "double hop" problem.
Suggested readings:
http://msdn.microsoft.com/en-us/library/ms189580(v=sql.105).aspx
http://www.sqlservercentral.com/Forums/Topic1043330-359-1.aspx
Viewing 4 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply