views:

50

answers:

2

Is it possible to create database in linked server? If yes then how.

I appreciate your help. Thank You.

A: 

See:

You basically need to call the sp_addlinkedserver stored proc:

sp_addlinkedserver
     [ @server= ] 'server' [ , [ @srvproduct= ] 'product_name' ] 
     [ , [ @provider= ] 'provider_name' ]
     [ , [ @datasrc= ] 'data_source' ] 
     [ , [ @location= ] 'location' ] 
     [ , [ @provstr= ] 'provider_string' ] 
     [ , [ @catalog= ] 'catalog' ] 

Something like:

EXEC sp_addlinkedserver  @server='S1_instance1', @srvproduct='',
                         @provider='SQLNCLI', @datasrc='S1\instance1'

For details, see the MSDN docs - it's really pretty good!

marc_s
+2  A: 

If your linked server allows it, then you can run sp_executesql remotely and by that means you can do absolutely anything on the linked server. Eg. create a database:

exec <linkedserver>.master.sys.sp_execute_sql N'create database foo';
Remus Rusanu