Public Sub ExecuteSQLScriptFile(cn as ADODB.Connection,sqlFile As String)Dim strSql As String, strTmp As StringOpen sqlFile For Input As #1strSql = ""Do While Not EOF(1)Line Input #1, strTmpIf UCase$(strTmp) = "GO" Thencn.Execute strSqlstrSql = ""ElsestrSql = strSql & strTmp & vbCrLfEnd IfLoopIf strSql <> "" Then cn.Execute strSqlClose #1End Sub2.Public Sub ExecuteSQLScriptFile(cn as ADODB.Connection,sqlFile As String)Dim sql as string sql="master.dbo.xp_cmdshell ' osql -U username -P password -i " & sqlFilecn.execute sqlEnd Sub

评论