Solved

Stored procedure - Select with parameters

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Webservices in T-SQL 3 30
convert null in sql server 12 31
Create snapshot on MSSQL 2012 3 16
sql server service accounts 4 19
In this article I will describe the Copy Database Wizard 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.
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
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.

815 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

9 Experts available now in Live!

Get 1:1 Help Now