Solved

having problem with a query

Posted on 2006-06-22
5
310 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
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

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

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
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 backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how the fundamental information of how to create a table.

707 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

15 Experts available now in Live!

Get 1:1 Help Now