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.
| Author |
Topic |
|
steven.liberman1
Starting Member
15 Posts |
Posted - 2011-02-16 : 12:21:21
|
| USE [Version500_test!!!]GOSET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO-- ================================================================-- Author: Steven Liberman-- Create date: February 14, 2011-- Description: WEB_SO_Analyze-- exec WEB_SO_Analyze -- ================================================================alter procedure dbo.WEB_SO_Analyze(@department_id int,@without_rota float output, @with_rota float output,@pct_with_rota float output)AS Begin set @without_rota=20; set @with_rota=2; set @pct_with_rota=1; -- select * from employee order by emp_id set @without_rota = (select count(emp_id) from dbo.employee where @department_id = emp_department_id and emp_dt_termination is not NuLL) set @with_rota = (select count(emp_id) from dbo.employee where @department_id = emp_department_id and emp_dt_termination is NuLL) --final function which calculates percentage set @pct_with_rota = (@with_rota/(@without_rota+@with_rota)); print @without_rota print @with_rota print @pct_with_rota EndGoOK this is my code now, but the stored procedure is not executing or working properly |
|
|
revdnrdy
Posting Yak Master
220 Posts |
Posted - 2011-02-16 : 12:31:46
|
quote: Originally posted by steven.liberman1 USE [Version500_test!!!]GOSET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO-- ================================================================-- Author: Steven Liberman-- Create date: February 14, 2011-- Description: WEB_SO_Analyze-- exec WEB_SO_Analyze -- ================================================================alter procedure dbo.WEB_SO_Analyze(@department_id int,@without_rota float output, @with_rota float output,@pct_with_rota float output)AS Begin set @without_rota=20; set @with_rota=2; set @pct_with_rota=1; -- select * from employee order by emp_id set @without_rota = (select count(emp_id) from dbo.employee where @department_id = emp_department_id and emp_dt_termination is not NuLL) set @with_rota = (select count(emp_id) from dbo.employee where @department_id = emp_department_id and emp_dt_termination is NuLL) --final function which calculates percentage set @pct_with_rota = (@with_rota/(@without_rota+@with_rota)); print @without_rota print @with_rota print @pct_with_rota EndGoOK this is my code now, but the stored procedure is not executing or working properly
This is the syntax I would use.. Its from an adventureworks example.Does this help you figure out your code?declare @without_rota Nvarchar(100)set @without_rota=20;SET @without_rota = 'SELECT count(*) from [Orders]' + ' where OrderId < 1000'Also you do not need the semicolons at the end of your SET statements. It does not hurt to have them but its not required.r&r |
 |
|
|
Ifor
Aged Yak Warrior
700 Posts |
|
|
|
|
|