Results 1 to 4 of 4

Thread: Setting SQL Permission using DOS command

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2006
    Posts
    73

    Setting SQL Permission using DOS command

    hi all,
    i would like to know the DOS command for the command in setting the permission in a SQL Server/DB. hope someone can help me in this. thks a million in advance.

    longwar

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Setting SQL Permission using DOS command

    You would run query analyzer from the command prompt passing the sql text as a parameter. This can also be done as a bat file or shelled in most other languages. [/color]
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Setting SQL Permission using DOS command

    There is a command line version of QUERY ANALYZER that can run at a DOS prompt. With it you can execute QUERIES against a server/database.

    From BOL:

    osql Utility
    The osql utility allows you to enter Transact-SQL statements, system procedures, and script files. This utility uses ODBC to communicate with the server.

    Syntax
    osql
    [-?] |
    [-L] |
    [
    {
    {-U login_id [-P password]}
    | –E
    }
    [-S server_name[\instance_name]] [-H wksta_name] [-d db_name]
    [-l time_out] [-t time_out] [-h headers]
    [-s col_separator] [-w column_width] [-a packet_size]
    [-e] [-I] [-D data_source_name]
    [-c cmd_end] [-q "query"] [-Q "query"]
    [-n] [-m error_level] [-r {0 | 1}]
    [-i input_file] [-o output_file] [-p]
    [-b] [-u] [-R] [-O]
    ]
    Operating-System Commands
    Operating-system commands can also be executed by starting a line with two exclamation points (!!) followed by the command. The command recall facilities of Windows NT can be used to recall and modify osql statements. The existing query buffer can be cleared by typing RESET.

    When running stored procedures, osql prints a blank line between each set of results in a batch. In addition, the "0 rows affected" message does not appear when it does not apply to the statement executed.

    Using osql Interactively
    To use osql interactively, type the osql command (and any of the options) at a command prompt.

    You can read in a file containing a query (such as Stores.qry) for execution by osql by typing a command similar to this:

    osql /U alma /P /i stores.qry

    The file must include a command terminator(s).

    You can read in a file containing a query (such as Titles.qry) and direct the results to another file by typing a command similar to this:

    osql /U alma /P /i titles.qry /o titles.res

    When using osql interactively, you can read an operating-system file into the command buffer with :r file_name. Do not include a command terminator in the file; enter the terminator interactively after you have finished editing.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Setting SQL Permission using DOS command

    Yes, thats what I was refering to but I didnt state teh query analyzer filename as I couldnt remember the difference between the isqlw and osql?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width