sql server 2008 - Multi- part identifier "" could not be bound -
i hope can new sql server pleaes patient. i'm trying set variable case statement hitting mulit-identifier error. code trying parse value variable depending on date variables being within date ranges of 2 date fields.
use kssdb declare @datefrom datetime, @dateto datetime, @resint int, @progid int, @persid int set @datefrom = '2010/11/01' set @dateto = '2013/11/01' set @progid = 63 set @persid = 4492 --select pt.prog_id, -- pt.pers_id, -- p.prog_name, -- format(pt.prog_trai_sd, 'dd/mm/yyyy') prog_trai_sd, -- format(pt.prog_trai_ed, 'dd/mm/yyyy')as prog_trai_ed, set @resint = case when (@datefrom > pt.prog_trai_sd , @dateto < pt.prog_trai_ed) 1 when (@datefrom > pt.prog_trai_ed , @dateto > pt.prog_trai_ed) 2 when (@datefrom < pt.prog_trai_sd , @dateto > pt.prog_trai_ed) 3 else 0 end select @resint prog p join prog_trai pt on p.prog_id = pt.prog_id pt.prog_id = @progid , pt.pers_id = @persid
the problem case
statement separate select ... from
, attempting set @resint
using data in table.
try using this:
select @resint = case when (@datefrom > pt.prog_trai_sd , @dateto < pt.prog_trai_ed) 1 when (@datefrom > pt.prog_trai_ed , @dateto > pt.prog_trai_ed) 2 when (@datefrom < pt.prog_trai_sd , @dateto > pt.prog_trai_ed) 3 else 0 end prog p join prog_trai pt on p.prog_id = pt.prog_id pt.prog_id = @progid , pt.pers_id = @persid
Comments
Post a Comment