October 2, 2015 at 5:36 am
Hi,
I have managed to successfully connect to another SQL Server instance using a linked server.
I can then do my select statement like this:
select * from [servername\instancename].[databasename].[databaseowner].[tablename]
I just wanted to know how I can drop the database on the other instance?
I have tried doing: DROP DATABASE [servername\instancename].[databasename]
but it doesn't work and expects a database name.
October 2, 2015 at 5:45 am
Try this
EXEC [yourlinkedserver].tempdb.dbo.sp_executesql N'DROP DATABASE Test;';
Need to ensure RPC is on in the linked server settings
October 2, 2015 at 6:06 am
i believe the command syntax like this will work as well: i use it for creating tables remotely:
EXEC ('DROP DATABASE [SandBox]') AT MyLinkedServer
Lowell
October 2, 2015 at 7:19 am
They work thanks.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply