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 in SP

Author  Topic 

jung1975
Aged Yak Warrior

503 Posts

Posted - 2004-09-21 : 16:34:05
I keep getting a syntax error:Incorrect syntax near the keyword 'from'. I am not sure what is wrong..


create proc Test( @orgid int )
as

If exists ( select * from dbo.A where @orgid = child_key_code )
Begin
select count(distinct(p_id)) from dbo.A
where child_key_code = @orgid and ref_stat_dt between '20030121' and '20040921'
end

else

begin
select count(distinct(p_id) from dbo.A
where ref_stat_dt between '20030121' and '20040921'
end



nr
SQLTeam MVY

12543 Posts

Posted - 2004-09-21 : 16:47:47
select count(distinct p_id) from dbo.A

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -