![]() ![]() Re: Macro to run SQL Stored Procedure and Pass Parameter I know the stored procedure works directly in SQL Server Management Studio and I know my stored procedure code works, it's the addtional: UPDATE LOGProcs SET DateEnded = GETDATE() WHERE Serial = END. ![]() WHERE SampleTypeID = '4' AND Fieldwork_Month = ELSE.- Insert statements for procedure here.INSERT INTO LOGProcs (ProcRan) VALUES (' AS VARCHAR(50))).- SET NOCOUNT ON added to prevent extra result sets from.- Add the parameters for the stored procedure here.Application.StatusBar = "Data successfully updated.".If rs.EOF = False Then WSP1.Cells(1, 1).CopyFromRecordset rs.' Copy the results to cell A1 on the first Worksheet.Set rs = cmd.Execute(,, adCmdStoredProc).cmd.Parameters("MonthVarb").Value = SP_Param.Set prm = cmd.CreateParameter("MonthVarb", adVarChar, adParamInput).Application.StatusBar = "Running stored procedure.".con.Open "Provider=SQLOLEDB Data Source=" & ServerName & " Initial Catalog=" & DatabaseName & " User ID=" & UserID & " Password=" & Password & " Trusted_Connection=no".' Log into our SQL Server, and run the Stored Procedure.SP_Param = "September 12" ' Enter Parameter Here.StoredProcedure = "usp_SampleAnalysis" ' Enter Stored Procedure here.Password = "" ' Enter your password here.DatabaseName = "" ' Enter your database name here. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |