我不确定将字符串转换为VBscript
...的意思...就像 Ansgar Wiechers 所说,字符串保持不变,
无论如何环境都会发生变化...
将此代码放入notepad.exe
编辑连接字符串以适合您的服务器
保存文件的.vbs
扩展名
找到它并运行它!
Const adUseClient = 3
Dim cn
Set cn = CreateObject("ADODB.Connection")
dim sql
sql = "SELECT distinct CASE " & _
"WHEN enty_typ_cd = 'acct' THEN 'Account : ' " & _
"WHEN enty_typ_cd = 'pfolio' THEN 'Portfolo : ' " & _
"END + a.mstr_shrt_nm_id as [ ] " & _
"FROM RCMglbl..nav_nt a, RCMglbl..enty_mstr b " & _
"WHERE a.enty_id = b.id AND office = 'sf' " & _
"AND mnth_end_dt <> (select lst_mo_end_dt from RCMglbl..proc_dt) " & _
"AND mnth_end_dt is not NULL"
with cn
.CursorLocation = adUseClient
.Open "Driver={SQL Server};Server=SERVER_NAME; Database=DATABASE_NAME; UID=USER_ID_NAME; PWD=PASSWORD"
.CommandTimeout = 0
.Execute(sql)
end with
cn.close
set cn = Nothing
一旦你开始工作,你必须考虑你从查询中得到的结果......因此,我建议阅读更多关于SELECT STATEMENT和可能的RECORDSET