sqlcmd -S <compname>\SQLEXPRESS -d <dbname> -i hoge.sql
sp_addlinkedserver N'LinkSQLSrvr', ' ', N'SQLOLEDB', N'KNLDB001\SQLDEV' GO sp_addlinkedsrvlogin N'LinkSQLSrvr', false, N'iyada', N'kaeritai', N'madakaerenai' GOこれで直接SQLを実行することが可能になる。
select * from LinkSQLSrvr.db2.dbo.tenpo
Within SQL-DMO, collections represent a group of Microsoft® SQL Server™ components. The meaning of the collection, the components referenced from the objects contained, is visible in the collection's name. For example, the Operators collection contains Operator objects that reference SQL Server Agent operators.とのこと
using System; using System.Diagnostics; using SQLDMO; using System.Collections; public class SqlDmo { static public String mServerName = "サーバ名適当に"; static public String mUserName = "ユーザ名"; static public String mPassword = "パスワード"; static public void Test() { try { Debug.WriteLine("----DB名列挙----"); SQLDMO.SQLServer sv = new SQLDMO.SQLServerClass(); sv.Connect(mServerName, mUserName, mPassword); int c = sv.Databases.Count; for(int i = 1; i <= c ; i++ ) { _Database db = sv.Databases.Item(i,"SA"); Debug.WriteLine("DB"+ i + ":" + db.Name ); } Debug.WriteLine("----Drive列挙----"); QueryResults qr = sv.EnumAvailableMedia( SQLDMO_MEDIA_TYPE.SQLDMOMedia_FixedDisk); for( int i = 1; i <= qr.Rows; i++ ) { String s = qr.GetColumnString(i,1); Debug.WriteLine("DRV" + i + ":" + s); } Debug.WriteLine("----フォルダ名列挙----"); QueryResults qr2 = sv.EnumDirectories("c:\\"); for( int i = 1; i <= qr2.Rows; i++ ) { String s = qr2.GetColumnString(i,1); Debug.WriteLine("DIR" + i + ":" + s); } sv.DisConnect(); Debug.WriteLine("----end----"); } catch(Exception ex) { Debug.WriteLine(ex.Message); } } }