How to list all dates between two dates [duplicate]

You can use a numbers table: DECLARE @Date1 DATE, @Date2 DATE SET @Date1 = ‘20150528’ SET @Date2 = ‘20150531’ SELECT DATEADD(DAY,number+1,@Date1) [Date] FROM master..spt_values WHERE type=”P” AND DATEADD(DAY,number+1,@Date1) < @Date2 Results: ╔════════════╗ ║ Date ║ ╠════════════╣ ║ 2015-05-29 ║ ║ 2015-05-30 ║ ╚════════════╝

How do I execute a stored procedure once for each row returned by query?

use a cursor ADDENDUM: [MS SQL cursor example] declare @field1 int declare @field2 int declare cur CURSOR LOCAL for select field1, field2 from sometable where someotherfield is null open cur fetch next from cur into @field1, @field2 while @@FETCH_STATUS = 0 BEGIN –execute your sproc on each row exec uspYourSproc @field1, @field2 fetch next from … Read more

Does Entity Framework Code First support stored procedures?

EDIT: My original answer for EF4.1 (below) is now out of date. Please see the answer below from Diego Vega (who works on the EF team at Microsoft)! @gsharp and Shawn Mclean: Where are you getting this information? Don’t you still have access to the underlying ObjectContext? IEnumerable<Customer> customers = ((IObjectContextAdapter)this) .ObjectContext.ExecuteStoreQuery<Customer>(“select * from customers”); … Read more

Dapper.NET and stored proc with multiple result sets

QueryMultiple supports the ability to deal with multiple result sets. The only design restriction we added was totally disabling buffering for the grid reader. This means the whole API is streaming. In the simplest case you can use: var grid = connection.QueryMultiple(“select 1 select 2”); grid.Read<int>().First().IsEqualTo(1); grid.Read<int>().First().IsEqualTo(2); In the slightly more sophisticated case you can … Read more

Retrieving Multiple Result sets with stored procedure in php/mysqli

I think you’re missing something here. This is how you can get multiple results from stored procedure using mysqli prepared statements: $stmt = mysqli_prepare($db, ‘CALL multiples(?, ?)’); mysqli_stmt_bind_param($stmt, ‘ii’, $param1, $param2); mysqli_stmt_execute($stmt); // fetch the first result set $result1 = mysqli_stmt_get_result($stmt); // you have to read the result set here while ($row = $result1->fetch_assoc()) { … Read more

How to write a stored procedure using phpmyadmin and how to use it through php?

Since a stored procedure is created, altered and dropped using queries you actually CAN manage them using phpMyAdmin. To create a stored procedure, you can use the following (change as necessary) : CREATE PROCEDURE sp_test() BEGIN SELECT ‘Number of records: ‘, count(*) from test; END// And make sure you set the “Delimiter” field on the … Read more