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 |
|
gualm
Starting Member
11 Posts |
Posted - 2007-12-27 : 10:29:49
|
| Msg 102, Level 15, State 1, Line 6 which is around the comment line where is shows monthly and other. Getting message incorrect systax near '/'. @Frequency varchar(1), -- 'M' = Monthly, 'O' = Other @FiscalPeriod smallint, @FiscalYear smallintasset nocount onDECLARE @DateFrom datetime, @DateTo datetime SET @DateFrom = CASE @Frequency WHEN 'M' THEN convert(varchar,( SELECT efsc_from_date FROM rs3_reporting.dbo.rs_entity_fiscal (NOLOCK) WHERE efsc_to_date = ( SELECT max(efsc_to_date) FROM rs3_reporting.dbo.rs_entity_fiscal (NOLOCK) WHERE efsc_to_date < getdate())),101) + ' 00:00:00' WHEN 'O' THEN convert(varchar,( SELECT efsc_from_date FROM rs3_reporting.dbo.rs_entity_fiscal (NOLOCK) WHERE efsc_fiscal_year = @FiscalYear and efsc_fiscal_period = @FiscalPeriod),101) + ' 00:00:00' ELSE convert(varchar,getdate()-1,101) END SET @DateTo = Case @Frequency WHEN 'M' THEN convert(varchar,( SELECT efsc_to_date FROM rs3_reporting.dbo.rs_entity_fiscal (NOLOCK) WHERE efsc_to_date = ( SELECT max(efsc_to_date) FROM rs3_reporting.dbo.rs_entity_fiscal (NOLOCK) WHERE efsc_to_date < getdate())),101) + ' 23:59:59' WHEN 'O' THEN convert(varchar,( SELECT efsc_to_date FROM rs3_reporting.dbo.rs_entity_fiscal (NOLOCK) WHERE efsc_fiscal_year = @FiscalYear and efsc_fiscal_period = @FiscalPeriod),101) + ' 00:00:00' ELSE convert(varchar,getdate()-1,101) END SET @FiscalPeriod = CASE @Frequency WHEN 'O' THEN @FiscalPeriod ELSE (SELECT efsc_fiscal_period FROM rs3_reporting.dbo.rs_entity_fiscal (NOLOCK) WHERE efsc_to_date = ( SELECT max(efsc_to_date) FROM rs3_reporting.dbo.rs_entity_fiscal (NOLOCK) WHERE efsc_to_date < getdate() ) ) END SET @FiscalYear = CASE @Frequency WHEN 'O' THEN @FiscalYear ELSE (SELECT efsc_fiscal_year FROM rs3_reporting.dbo.rs_entity_fiscal (NOLOCK) WHERE efsc_to_date = ( SELECT max(efsc_to_date) FROM rs3_reporting.dbo.rs_entity_fiscal (NOLOCK) WHERE efsc_to_date < getdate() ) ) END |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-12-27 : 10:43:52
|
| try@Frequency varchar(1), -- 'M' = Monthly, 'O' = Otherotherwise I don't think the error is in the code you have shown.==========================================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. |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2007-12-27 : 10:50:57
|
| Are any of the "tables" you are selecting from actually Views or functions? If so, you will need to try simply running the subqueries first individually to see if they perform as expected.Be One with the OptimizerTG |
 |
|
|
|
|
|
|
|