Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2002

    Question Unanswered: Acessing SQL through a DOS login script

    Does anybody know if it is possible to pass an NT Environment variable to an SQL Server and then return the results back to the DOS?

    Example: when a user logs in, their username is stored in the environment variable %USERNAME%. I would like to send this to SQL and then look up their department and then depending on what department they are in, different drives are mapped.

    I think this would be done with stored procedures, but I am quite new to these.

    Many thanks in advance
    Matt Cottrell

  2. #2
    Join Date
    Dec 2001
    Toronto, Canada
    Yes I believe you can, try this from DOS, substring in your login criteria

    isql -Uxx -Pxx -Sxx -n -Q"PRINT '%USERNAME%'"
    You can then create a stored procedure that "PRINTS" out the drive mapping

    "NET USE D: \\Server\Home "

    Have your script file pass the USERNAME in then redirect the output to a file and run the file from the DOS command script

    isql -Uxx -Pxx -Sxx -n -Q"sp_MakeMappings '%USERNAME%'" -oC:\temp\mapping.cmd
    del C:\temp\mapping.cmd

Posting Permissions

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