Re: Sql Query

From: Ray Costanzo [MVP] (myfirstname)
Date: 08/20/04

  • Next message: guard: "Re: Get today's date no matter what format is in use."
    Date: Fri, 20 Aug 2004 18:47:06 -0400
    
    

    Oops. I forgot to write the recordset... That would probably be helpful.

    If WScript.Arguments.Count > 0 Then WScript.StdOut.Write
    ReturnRS(WScript.Arguments(0))

    INSTEAD OF

    If WScript.Arguments.Count > 0 Then Call ReturnRS(WScript.Arguments(0))

    Ray at home

    "Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
    message news:O0l2FnshEHA.1964@tk2msftngp13.phx.gbl...
    > osql won't connect to an AS/400, only SQL Server, AFAIK. Are you familiar
    > with VB Script at all? You could ~~try~~ something like this after
    > registering cscript to be the default script host. (cscript.exe
    > //H:CScript)
    >
    >
    > csql.vbs:
    >
    > If WScript.Arguments.Count > 0 Then Call ReturnRS(WScript.Arguments(0))
    >
    >
    > ''connection string from www.connectionstrings.com
    > Const CONNECTION_STRING = "Provider=DB2OLEDB;Network Transport
    > Library=TCPIP;Network Address=XXX.XXX.XXX.XXX;Initial
    Catalog=MyCtlg;Package
    > Collection=MyPkgCol;Default Schema=Schema;User ID=MyUser;Password=MyPW"
    > Function ReturnRS(sql)
    > Dim oADO, oRS
    > Set oADO = CreateObject("ADODB.Connection")
    > oADO.Open CONNECTION_STRING
    > Set oRS = oADO.Execute(sql)
    > If Not oRS.EOF Then ReturnRS = oRS.GetString(2,,vbTab,vbCrLf)
    > oADO.Close
    > Set oADO = Nothing
    > End Function
    >
    >
    >
    > And then call it with:
    >
    > csql "select something from somwhere where something='something'"
    >
    > This is probably far from ideal though! There's probably a command prompt
    > "osql" for DB/2 out there somewhere already...
    >
    > Ray at work
    >
    >
    >
    >
    > "Barney" <anonymous@discussions.microsoft.com> wrote in message
    > news:9c9601c486ad$bbb03cd0$a401280a@phx.gbl...
    > > We dont have an SQL server - we have an AS400 running
    > > DB2. Where can I download osql.exe?
    > >>-----Original Message-----
    > >>Use osql.exe in your batch, which you should have from
    > > any SQL Server
    > >>installation, including the "client tools only" install.
    > >>
    > >>osql -?
    > >>
    > >>usage: osql [-U login id] [-P
    > > password]
    > >> [-S server] [-H hostname] [-E
    > > trusted connection]
    > >> [-d use database name] [-l login timeout] [-t
    > > query timeout]
    > >> [-h headers] [-s colseparator] [-w
    > > columnwidth]
    > >> [-a packetsize] [-e echo input] [-I
    > > Enable Quoted
    > >>Identifiers]
    > >> [-L list servers] [-c cmdend] [-D ODBC
    > > DSN name]
    > >> [-q "cmdline query"] [-Q "cmdline query" and exit]
    > >> [-n remove numbering] [-m errorlevel]
    > >> [-r msgs to stderr] [-V severitylevel]
    > >> [-i inputfile] [-o outputfile]
    > >> [-p print statistics] [-b On error batch abort]
    > >> [-O use Old ISQL behavior disables the following]
    > >> <EOF> batch processing
    > >> Auto console width scaling
    > >> Wide messages
    > >> default errorlevel is -1 vs 1
    > >> [-? show syntax summary]
    > >>
    > >>Ray at work
    > >>
    > >>"Patrick Bonneau" <anonymous@discussions.microsoft.com>
    > > wrote in message
    > >>news:84b001c48525$712aefe0$a401280a@phx.gbl...
    > >>> Is there away to make a sql query with a batch file?
    > >>>
    > >>> If so, what is the utility for doing this?
    > >>>
    > >>
    > >>
    > >>.
    > >>
    >
    >


  • Next message: guard: "Re: Get today's date no matter what format is in use."

    Relevant Pages

    • Re: Retrieving Data from Excel by using ASP
      ... Dim oADO, oRS, sSQL ... Set oADO = CreateObject ... Set oRS = oADO.Execute ... > Yeah I agree with you Ray. ...
      (microsoft.public.inetserver.asp.general)
    • Re: Retrieving Data from Excel by using ASP
      ... Set oRS = oADO.Execute ... Response.Write sSQL ... > Hi Ray I know am making it much harder but be patient with me please. ... > Error Type: ...
      (microsoft.public.inetserver.asp.general)
    • Re: text file data
      ... Ray at home ... >> Dim oADO ... >> msgbox oRS.Fields.Item.Value ...
      (microsoft.public.scripting.vbscript)