locked
how can I make this work RRS feed

  • Question

  • DECLARE @database varchar(12)

    SET @database= 'FedEx'

    SELECT

    * FROM @database.Appeal

    in the above sql am passing database name as variable and selecting data from that database. any idea how to do this
    • Edited by ghankot Tuesday, September 22, 2009 6:22 PM
    Tuesday, September 22, 2009 6:13 PM

Answers

  • try this
    DECLARE @db varchar(12)
    
    SET @db = 'rcomdenials'
    
    exec ('SELECT * FROM '+ @db + '..appAppeal')
    • Marked as answer by ghankot Tuesday, September 22, 2009 6:21 PM
    Tuesday, September 22, 2009 6:18 PM

All replies

  • try this
    DECLARE @db varchar(12)
    
    SET @db = 'rcomdenials'
    
    exec ('SELECT * FROM '+ @db + '..appAppeal')
    • Marked as answer by ghankot Tuesday, September 22, 2009 6:21 PM
    Tuesday, September 22, 2009 6:18 PM
  • thank you, that did work
    Tuesday, September 22, 2009 6:22 PM