Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: SQL Query Password/User ID


From   "Joseph Coveney" <[email protected]>
To   "Statalist" <[email protected]>
Subject   st: Re: SQL Query Password/User ID
Date   Fri, 14 Dec 2007 12:31:29 +0900

I wrote:

I haven't tested this out, and so it might need a little tweaking.

--------------------------------------------------------------------------------

The do-file below should help in any tweaking efforts.  For use, substitute
"odbc" for "display in smcl as result" in the program.

Joseph Coveney

clear *
set more off
capture program drop myodbc
program define myodbc
   version 10
   syntax anything(everything) [, *]
   capture assert "$us" == ""
   if !_rc display in smcl as text "What's your user ID" _request(us)
   capture assert "$pw" == ""
   if !_rc display in smcl as text "What's your password" _request(pw)
   if (`"`anything'"' == "list") display in smcl as result "odbc list"
   else display in smcl as result ///
     "odbc " `"`anything'"' ", " `"`options'"' " user($us) password($pw)"
end
*
local dsn MyDSN
local file C:/Files/My File.SQL
myodbc list
myodbc query "`dsn'", dialog(required)
myodbc describe "[My Table]", dsn("`dsn'") dialog(complete)
myodbc load here there everywhere ///
 if nowhere == "nothing", table("[My Table]")
myodbc load , exec("SELECT * FROM [My Table]") dsn("`dsn'")
myodbc sqlfile("`file'"), dsn("`dsn'")
myodbc exec("SELECT a, b FROM [My Table]"), dsn("`dsn'")
exit


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index