mirror of
https://github.com/Microsoft/sql-server-samples.git
synced 2025-12-08 14:58:54 +00:00
Spread strings longer than allowed over multiple lines
This commit is contained in:
@@ -32,7 +32,9 @@ while ($row = sqlsrv_fetch_array($getProducts, SQLSRV_FETCH_ASSOC)) {
|
||||
|
||||
sqlsrv_free_stmt($getProducts);
|
||||
|
||||
$tsql = "INSERT SalesLT.Product (Name, ProductNumber, StandardCost, ListPrice, SellStartDate) OUTPUT INSERTED.ProductID VALUES ('SQL Server 15', 'SQL Server 12', 0, 0, getdate())";
|
||||
$tsql = "INSERT SalesLT.Product (Name, ProductNumber, StandardCost, ListPrice, SellStartDate)
|
||||
OUTPUT INSERTED.ProductID
|
||||
VALUES ('SQL Server 15', 'SQL Server 12', 0, 0, getdate());";
|
||||
|
||||
$insertReview = sqlsrv_query($conn, $tsql);
|
||||
if ($insertReview == false) {
|
||||
|
||||
+9
-2
@@ -94,14 +94,21 @@ if ($getProducts == false) {
|
||||
echo "Error deleting the UDF";
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
}
|
||||
$tsql1 = "CREATE FUNCTION dbo.ifGetTotalItems (@OrderID INT) RETURNS TABLE WITH SCHEMABINDING AS RETURN (SELECT SUM(OrderQty) AS TotalItems FROM SalesLT.SalesOrderDetail WHERE SalesOrderID = @OrderID GROUP BY SalesOrderID);";
|
||||
$tsql1 = 'CREATE FUNCTION dbo.ifGetTotalItems (@OrderID INT) RETURNS TABLE WITH SCHEMABINDING AS RETURN (
|
||||
SELECT SUM(OrderQty) AS TotalItems FROM SalesLT.SalesOrderDetail
|
||||
WHERE SalesOrderID = @OrderID
|
||||
GROUP BY SalesOrderID
|
||||
);';
|
||||
$getProducts = sqlsrv_query($conn, $tsql1);
|
||||
//Error handling
|
||||
if ($getProducts == false) {
|
||||
echo "Error creating the UDF";
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
}
|
||||
$tsql1 = "SELECT s.SalesOrderID, s.OrderDate, s.CustomerID, f.TotalItems FROM SalesLT.SalesOrderHeader s CROSS APPLY dbo.ifGetTotalItems(s.SalesOrderID) f ORDER BY SalesOrderID;";
|
||||
$tsql1 = "SELECT s.SalesOrderID, s.OrderDate, s.CustomerID, f.TotalItems
|
||||
FROM SalesLT.SalesOrderHeader s
|
||||
CROSS APPLY dbo.ifGetTotalItems(s.SalesOrderID) f
|
||||
ORDER BY SalesOrderID;";
|
||||
$getProducts = sqlsrv_query($conn, $tsql1);
|
||||
//Error handling
|
||||
if ($getProducts == false) {
|
||||
|
||||
Reference in New Issue
Block a user