Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2006
    Posts
    21

    Unanswered: Selecting current database

    Hello,

    When I open a query analyzer , of a particular database for example 'AB'

    when writting a query how can I get the databasename that I am executing

    i.e in the result I should get the DB name.

    I was trying select name from master..sysdatabases . But it was returning all DB names.

    Also while running a query , can I prompt for the DB name , so that that particular db name can be used to run that procedure or query.

    Thanks in advance

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by dvaddi
    Hello
    Hello!

    Quote Originally Posted by dvaddi
    when writting a query how can I get the databasename that I am executing

    i.e in the result I should get the DB name.
    Code:
    
    SELECT db_name(0)
    
    Quote Originally Posted by dvaddi
    Also while running a query , can I prompt for the DB name , so that that particular db name can be used to run that procedure or query.
    Not with query analyser. That is a client application kind of function.

    HTH
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    Quote Originally Posted by pootle flump
    That is a client application kind of function.
    really? I like to pop a message box from my CLR triggers to make sure the user really wants to commit the data.

Posting Permissions

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