Solved

Stored procedure - Select with parameters

Posted on 2013-01-09
1
288 Views
Last Modified: 2013-01-09
I am trying to do a SP that will simply select from a table and use parameters.
This is what I have so far but the syntax seems to be wrong:

--

CREATE procedure [dbo].[Select_ActivityLog]
@Actdesc NVARCHAR (150) , @Module NVARCHAR (150)

SELECT Id ,
        Firmid ,
        Userid ,
        Actdate ,
        Actdesc ,
        Actstatus ,
        Actdetails ,
        Module ,
        Fileuserid
 FROM dbo.ActivitiesLog

 WHERE Actdesc = @Actdesc AND Module = @Module

GO

---

The ASP will pass the parameters to the SP. I am using SQL 2008 R2
0
Comment
Question by:amucinobluedot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 22

Accepted Solution

by:
Steve Wales earned 500 total points
ID: 38759255
You're missing the AS keyword

CREATE procedure [dbo].[Select_ActivityLog]
@Actdesc NVARCHAR (150) , @Module NVARCHAR (150)
AS
SELECT Id ,
        Firmid ,
        Userid ,
        Actdate ,
        Actdesc ,
        Actstatus ,
        Actdetails ,
        Module ,
        Fileuserid
 FROM dbo.ActivitiesLog
 WHERE Actdesc = @Actdesc AND Module = @Module
GO

Open in new window


CREATE PROCEDURE T-SQL Documentation, including examples: http://msdn.microsoft.com/en-us/library/ms187926%28v=sql.105%29.aspx
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question