How to convert stored procedure to SQL Server Compact Edition query -
i have stored procedure need convert standard query. since i'm using sql server compact, no stored procedures.
here stored procedure:
declare @colu nvarchar (max) , @hour int set @hour = datepart(hh, getdate() ) select @hour select @colu = case when @hour=24 '[12:00am(00:00)]' enter code here when @hour >12 , @hour <24 '['+ convert(varchar,@hour-12) +':00pm('+ convert(nvarchar ,@hour) +':00)]' when @hour=12 '[12:00pm(12:00)]' when @hour <12 , @hour >9 '['+convert(nvarchar ,@hour) +':00am('+ convert(nvarchar ,@hour) +':00)]' else '['+convert(nvarchar ,@hour) +':00am(0'+ convert(nvarchar ,@hour) +':00)]' end select @colu declare @sql nvarchar(max) set @sql= 'select id,'''+ @colu + ''' time table' -- add quote here select @sql exec sp_executesql @sql
like say, i'm kind of stumped here. ideas?
here code used determine time value , dynamically specify column name:
float basalrate = 0; datetime hourval = convert.todatetime(pumpedittime); if (hourval == null) { hourval = datetime.now; } int hourval = hourval.hour; int ampmhour = convert.toint32(hourval.tostring("hh")); string hourampm = string.empty; if (hourval == convert.toint32("24")) { hourampm = "[12:00am(00:00)]"; } else if ((hourval > 12) && (hourval < 24)) { hourampm = "[" + ampmhour + ":00pm(" + hourval + ":00)]"; } else if (hourval == 12) { hourampm = "[12:00pm(12:00)]"; } else if ((hourval < 12) && (hourval > 9)) { hourampm = "[" + ampmhour + ":00am(" + hourval + ":00)]"; } else { hourampm = "[" + ampmhour + ":00am(0" + hourval + ":00)]"; }
Comments
Post a Comment