The query would execute in seconds when running the code inside the stored proc, but executing the stored proc itself took minutes (5). i added all the parameters as local variables and assigned the parameters to local variables and suddenly my stored proc executes in seconds. Friday, September 25, 2009 300 PM. In this section, we will understand how we can create a stored procedure in SQL Server to search and filter out table data. In SQL Server, we generally use the WHERE clause to filter the results based upon some condition. And for searching, we can use the LIKE operator to find the result. Lets understand this execution, by implementing an. Problem 1, In Power Query I set the data source to direct query and execute a stored procedure. Preview returns data with no problems. When I close and apply, I get an error Microsoft SQL Incorrect syntax near the keyword 'exec'. Incorrect syntax near ')'. It doesn't make sense because the stored procedure works and returns data in power query. To create a procedure, open your local SQL server management studio. In Object Explorer, connect to an instance of Database Engine and then expand that instance. Expand Databases, expand the AdventureWorks2012 database, and then expand Programmability. Right-click Stored Procedures, and then click New Stored Procedure, you will see outputlike.