0

I would like to execute an sql query in excel sheet, i have a cell "date" when i enter a date, the value of this cell should be passed as a parameter to my query and i want to get data relatives to this date into my excel sheet. I proceeded as below : 1-I defined a cell date as input then for connection between excel ad sql server : 2- Data / Connect to Database Server/ Server Name / Log on Credentials / Use the following User Name and Password Then i selected the database then i rename the fileName and the friendly Name then i opened the definition tab in the connection Properties window, i put the command type as sql, in the command text i wrote my query and i put in the where clause the date of today finally i choose the cell where to put the data / ok. I get the result of today but i want to define the cell date as parameter of the query, i changed the command text and put an ? in the where clause but i got an alert "Aucune valeur donnée pour un ou plusieurs des paramètres requis." So please how can i define the cell date as a parameter to the sql query?

Gtari Abir
  • 69
  • 3
  • 12
  • See my answer given [here](https://stackoverflow.com/questions/49490189/export-stored-procedure-result-set-to-excel-in-ssms/49492612#49492612) and check your steps. Make sure to do Definitions > Parameters > and then select the cell where parameter value will be collected from. The answer it for a stored procedure but simple to see steps and you can always convert to sp especially if running the query frequently. – QHarr Apr 03 '18 at 11:35
  • I did the same steps, the only difference that i wrote the query on the command text, i didn't use a stored procedure but the fields with type nvarchar are blank in the excel and when i execute the query in the sql server i get all data, no null columns, have an idea why only columns with type nvarchar are blank in excel ? doesn't excel support varchar type ? – Gtari Abir Apr 03 '18 at 12:14
  • https://stackoverflow.com/questions/15365500/excel-ssis-query-returns-null-columns-in-excel-but-not-in-management-studio – QHarr Apr 03 '18 at 14:18
  • Does it make a difference if you format the nvarchar output columns in excel as Text before running the query? Don't know if you can use the FORMAT function in the query string. – QHarr Apr 03 '18 at 15:01

0 Answers0