Retrieving a login's default database name

  • Hello all.

    Is there a way I can retrieve the default database name for a user currently logged in?

    I am trying to write a script that creates a job. But when I call sp_add_job_step I need to supply the name of the database where the procedure which I want the job to run has been created. I don't know the name of the database where the procedure has been created, I only know it was created in the default database of the user running the script (which can be any user name). But if I don't supply a database name for sp_add_job_step, the step will use the master database and that's not good....

    Any ideas??

  • Check sys.server_principals

    --Ramesh


Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply