Solved

having problem with a query

Posted on 2006-06-22
5
315 Views
Last Modified: 2008-03-17
I am trying to run this stored procedre in MS sql server db

CREATE PROCEDURE ccim_getSponorSize( @chapter_id varchar(20)) AS

select count(*) as logid
from  ccim_ChapterSponsors
where ccim_ChapterSponsors.Customer = @chapter_id
and  ccim_ChapterSponsors.display_add ='1'
GO

the display_add field is an int field

it doesn't give any syntax error but when i press apply it gves this error

Error 21037

 Any help will be greatly appreciated

0
Comment
Question by:huzefaq
[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
5 Comments
 
LVL 6

Expert Comment

by:davbouchard
ID: 16962304
Can't have quotes for a int field.

and  ccim_ChapterSponsors.display_add = 1
0
 

Author Comment

by:huzefaq
ID: 16962776
it ried that also but still no luck

Also t runs fine on sql analyzer
0
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 16963148
show us the ddl for ccim_ChapterSponsors
and how you are executing the stored procedure...
also confirm which version / editon of sql server you are using..
0
 
LVL 26

Expert Comment

by:DireOrbAnt
ID: 16964154
Try this:
CREATE PROCEDURE ccim_getSponorSize
@chapter_id varchar(20)
AS
select count(*) as logid
from  ccim_ChapterSponsors
where ccim_ChapterSponsors.Customer = @chapter_id
and  ccim_ChapterSponsors.display_add = 1
GO

'1' vs 1 is fine, but it's always better to match the type when you can :)
0
 
LVL 3

Accepted Solution

by:
chhapia_chintak earned 500 total points
ID: 16967429
Because of followinig two reasons the error can occur

-This error occurs when editing a stored procedure in Enterprise Manager and the name of the stored procedure is different from the name specified in the CREATE PROCEDURE specified in your script.  Make sure that the stored procedure you specified, in this case procSummaryRev, is the same as the name of the original stored procedure when you are editing it.

- The error may have happened when you renamed the stored procedure in Enterprise Manager then you are trying to edit it and the name of the stored procedure in the script does not match the new name of the stored procedure.  You simply have to make sure their names are the same.

Hope this helps.



0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
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 UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

751 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