Home  /  Questions  /  Question

0   0
Mar 19, 2016

Executing CTE from VB.Net From Dynamic Parameter

I am having below mentioned CTE in SQL Server 2012. and want to execute the same in VB.net  ON BUTTON Click event 
Where Start date and End Date Will Come From Datetimepickers ...Please Help on the same

WITH cte as(
 SELECT  [Status], [Date], [Time], CAST([Date] as datetime) + CAST([Time] As datetime) As [datetime] 
  FROM MyTable 
  WHERE [Date] >= @StartDateAND [Date] <= @EndDate) 
    SELECT  [Status], [Date], [Time], 
            CASE WHEN [Date] = LAG([Date]) OVER (ORDER BY [datetime]) THEN 
                 CAST(DATEADD(MINUTE, DATEDIFF(MINUTE, LAG([datetime]) 
                 OVER (ORDER BY [datetime]), [datetime]), '00:00:00') as time)         
            END AS TimeDifferenceFROM cte


508   99.9
Apr 04, 2016
Are you using the SPARK ORM or ADO.NET, Entity Framework, NHibernate, or something else?

We can get you some sample code in SPARK. Any other technology you'll find ample examples on the internet. 
Just let us know.