locked
formula to write a select statement in excel sheet RRS feed

  • Question

  • I am trying to write a  select statment in the excel sheet.

    I have list of database,table names,columnname given in a spread sheet.I need to write a sql query in the excel sheet for the given records

    example:select count(1) from databasename.dbo.tablename where columnname = '18'

    i want to write above select statement in the excel sheet using the excel functions.

    I tried the below formula but it doesnt work"

    =concatenate("select count(1) from ",a29".dbo.",b29" where ",c29" = '18' ");

     

    where a29,b29,c29 are the cells in the excel sheet.

    Monday, June 6, 2011 5:32 PM

Answers

  • Try it like this...

    ="SELECT COUNT(1) FROM " & A29 & ".dbo. " & B29 & " WHERE " & C29 & " = '18'"
    


    Jason Long
    • Marked as answer by anki2010 Monday, June 6, 2011 6:11 PM
    Monday, June 6, 2011 5:51 PM

All replies

  • Try it like this...

    ="SELECT COUNT(1) FROM " & A29 & ".dbo. " & B29 & " WHERE " & C29 & " = '18'"
    


    Jason Long
    • Marked as answer by anki2010 Monday, June 6, 2011 6:11 PM
    Monday, June 6, 2011 5:51 PM
  • tHANKS JASON.
    Monday, June 6, 2011 6:11 PM