Solved

SQL Server Stored Procedure

Posted on 2012-04-11
4
317 Views
Last Modified: 2012-04-12
The following stored procedure is giving error "The function has too many arguments".
Kindly help.
------------------------------

USE [drugs]
GO
/****** Object:  StoredProcedure [dbo].[FetchReport1Graph]    Script Date: 04/11/2012 20:11:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[FetchReport1Graph]
(
   @Drug varchar(1000)
 )
as
 begin
   declare @strSelect varchar(1000)
      Begin Tran
      set @strSelect=  'select drugname, COUNT(patientId) as NumberDurg from AssessmentDrug where DrugName in(' + CAST(@Drug as varchar)+ ') group by DrugName'
       EXEC(@strSelect)
      Commit
 end
0
Comment
Question by:sanjay-gandhi
[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
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
parthmalhan earned 400 total points
ID: 37836211
try Below:



ALTER procedure [dbo].[FetchReport1Graph]
(
   @Drug varchar(1000)
 )
as
 begin
   declare @strSelect varchar(1000)
      Begin Tran
 set @strSelect=  'select drugname, COUNT(patientId) as NumberDurg from AssessmentDrug where DrugName in(''' + CAST(@Drug as varchar)+ ''') group by DrugName'
ALTER procedure [dbo].[FetchReport1Graph]
(
   @Drug varchar(1000)
 )
as
 begin
   declare @strSelect varchar(1000)
      Begin Tran
0
 
LVL 9

Assisted Solution

by:sachinpatil10d
sachinpatil10d earned 100 total points
ID: 37836215
Your StoreProcedure excepts only one parameter  @Drug varchar(1000)

so the storeprocedure call will be

exec [dbo].[FetchReport1Graph] '100'

Open in new window


may be you are using it like this

exec [dbo].[FetchReport1Graph] '100','100'

Open in new window


which gives following error

Msg 8144, Level 16, State 2, Procedure FetchReport1Graph, Line 0
Procedure or function FetchReport1Graph has too many arguments specified.

you can use it

exec [dbo].[FetchReport1Graph] '100,200'

Open in new window

0
 

Author Comment

by:sanjay-gandhi
ID: 37836261
Let me try and revert... getting slightly busy....will revert by evening...thanks.
0
 

Author Closing Comment

by:sanjay-gandhi
ID: 37837734
Thanks, works fine.
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Complex SQL Server WHERE CLause 9 40
semaphore timeout period has expired 1 30
SQL Server 2012 and core licensing 5 31
SQL query joining 6 tables in asp.net 4 29
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

734 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