Results 1 to 13 of 13

Thread: osql or isql

  1. #1
    Join Date
    May 2002
    Posts
    73

    Unanswered: osql or isql

    Guys:

    Im new in MS SQL and I have little experienco on IBM DB2. I want to run a simple select query on a table, but I want to do it automatically.... What do you recommend?? Where I can get information about OSQL or ISQL usage??'


    Best regards,

  2. #2
    Join Date
    May 2002
    Location
    New York
    Posts
    35
    What do you mean 'automatically'? You can create stored procedure and run it from Quiry Analyzer by name. You can define parameters for selection criteria. Go to Online Help or Transact SQL help in Query Analyzer.

  3. #3
    Join Date
    May 2002
    Posts
    73
    for example in Unix you have the cron option. Means that I create the *.sql script and I schedulle it to run at certain time

  4. #4
    Join Date
    Feb 2002
    Posts
    2,232
    You can use SQL Server Agent.

    Good luck.

  5. #5
    Join Date
    May 2002
    Location
    New York
    Posts
    35
    Go to Job Scheduling in Tools, Enterprise Manager. Use Create Job Wizard. Good luck.

  6. #6
    Join Date
    May 2002
    Posts
    73
    by the way, the query I use is very simple, select * from MEMBERS where MEM_ENTERED between '2002-05-06 00:00:00' and '2002-05-06 23:59:59'

    I need to use change the date everyday. It is posible or exist the value = current date / current time in MS SQL to avoid changind date/ time everyday..

    Regards

  7. #7
    Join Date
    May 2002
    Location
    New York
    Posts
    35
    Try this:
    SELECT * from MEMBERS
    where convert(char(10),mem_entered, 101)
    = convert(char(10),getdate(),101)

    You retrieve all the records entered for the day.

    Good luck

  8. #8
    Join Date
    May 2002
    Posts
    73

    getdate

    Thanks It works.
    Just one question more. With that query I can get data for the current date. How I could change it to get for the previous day ??

    In IBM DB2 I just made the date variable equal to current date - 1 day.
    I will appreciate it

  9. #9
    Join Date
    May 2002
    Location
    New York
    Posts
    35
    Use getdate()-1 instead of getdate()- current date

  10. #10
    Join Date
    May 2002
    Posts
    73

    getdate

    Thanks !!
    It works. I will put it as schedulled job.

  11. #11
    Join Date
    May 2002
    Posts
    73

    schedulled job

    I schedulled the job. But How I see the results?? Does it sends it to a log file??

  12. #12
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    809
    jeremas, is your goal is to run a sql script based on a cron job and dump the results to a text file?
    Paul Young
    (Knowledge is power! Get some!)

  13. #13
    Join Date
    May 2002
    Posts
    73

    query + txt file

    Thanks. I already found the way to run the query, schedule it and sending the results to a txt file. It was using the SQL Server Agent and job scheduling and properties.

    Regards,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •