Solved

Stored procedure - Select with parameters

Posted on 2013-01-09
1
274 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
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now