• Sean Lange (12/3/2013)


    Laura_SqlNovice (12/3/2013)


    Hi Guys,

    I need to execute sql server proc from MS Access or Excel... the proc has couple of parameters, but do not have any data comming out. Can we do that? And how we can do it so that user can enter values for parameter and execute the proc.

    Thanks in advance for the help.

    Laura

    You would execute it using VBA. I would think you would use textboxes or some other form of input for the parameter values.

    Agreed. You'll need to add a reference to the Microsoft ActiveX Data Objects library and then you use the ADODB.Connection data type, open your connection and fire your procedures.

    As a word of caution, Excel files tend to spread through network shares, email, USB drives, etc. Be careful of the connection string you define in your Excel file. You don't want to have a server/username/password combination spread throughout the world and leave your database wide open. If it were me, I'd make the user enter their connection information into a form (and don't let them save it) and then try to connect using what they entered. This will also help you restrict who can use the Excel file to run the procedure by granting execute on that procedure to those users who are authorized to use the utility.