Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 syntax error

Author  Topic 

phaze
Starting Member

42 Posts

Posted - 2005-03-16 : 12:40:39
create procedure COB_GetMotiveResults
@motive varchar(10)
as
select account, amount, motive
from COB.dbo.trans
if @motive = null
raiserror 'There was a problem'
where motive = @motive
and account!= 0
and amount != 0
and motive != 0


i get a syntax error on the raiserror line. can you explain why?

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-03-16 : 12:45:00
well of course you did.
you put it between a from and where.

so what are you trying to do?

Go with the flow & have fun! Else fight the flow
Go to Top of Page

phaze
Starting Member

42 Posts

Posted - 2005-03-16 : 13:07:51
well this is my original script

create procedure COB_GetMotiveResults
@motive varchar(10)
as
select account, amount, motive
from COB.dbo.trans
where motive = @motive

I'm trying to learn how to make it not allow nulls and return non zeros.

I would also like to learn how to make user friendly error messages if COB.dbo.trans doesn't exist.




Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-03-16 : 13:08:02
create procedure COB_GetMotiveResults
@motive varchar(10)
as
select account, amount, motive
from COB.dbo.trans
where motive = @motive
and account!= 0
and amount != 0
and motive != 0
if @@ROWCOUNT=0
raiserror 'There was a problem'


maybe?

Kristen
Go to Top of Page
   

- Advertisement -