This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DaysBetween (dStartDate => dEnrolledDate, | |
| dEndDate => dGraduationDate, | |
| nGPA => nFinalGPA, | |
| nDaysBetween => nDuration); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SET @a = dbo.Func1(@param1, @param2, @param3 + 1, @param4) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PROCEDURE Days_Between (dStartDate IN date, | |
| dEndDate IN date, | |
| nGPA IN OUT number, | |
| nDaysBetween OUT number) | |
| <procedure declarations and body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE FUNCTION dbo.Fn_gettoporders(@custid AS INT,@n AS INT, @test AS CHAR) | |
| RETURNS TABLE | |
| AS | |
| RETURN | |
| SELECT TOP(@n) * | |
| FROM sales.salesorderheader | |
| WHERE customerid = @custid | |
| ORDER BY totaldue DESC | |
| GO |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WITH mycte(x) AS (SELECT x = Convert( VARCHAR(1000), 'hello' ) | |
| UNION ALL | |
| SELECT Convert( VARCHAR(1000), x + 'a' ) | |
| FROM mycte | |
| WHERE Len( x ) < 10 | |
| UNION ALL | |
| SELECT Convert( VARCHAR(1000), x + 'b' ) | |
| FROM mycte | |
| WHERE Len( x ) < 10) | |
| SELECT x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT productnumber, | |
| name, | |
| 'Price Range' = CASE | |
| WHEN listprice = 0 THEN 'Mfg item - not for resale' | |
| WHEN listprice < 50 THEN 'Under $50' | |
| WHEN listprice >= 50 | |
| AND listprice < 250 THEN 'Under $250' | |
| WHEN listprice >= 250 | |
| AND listprice < 1000 THEN 'Under $1000' | |
| ELSE 'Over $1000' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE TABLE suppliers | |
| AS (SELECT * | |
| FROM companies | |
| WHERE id > 1000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE TABLE dbo.mytable ( low int, high int, myavg AS (low + high)/2 ) ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| UPDATE employees | |
| SET department_id = 70,dname = 'sales',location = 'ca' | |
| WHERE employee_id = 113; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| INSERT TOP (10) INTO HumanResources.NewEmployee | |
| SELECT | |
| e.BusinessEntityID, c.LastName, c.FirstName, pp.PhoneNumber, | |
| a.AddressLine1, a.City, sp.StateProvinceCode, | |
| a.PostalCode, e.CurrentFlag | |
| FROM HumanResources.Employee e | |
| INNER JOIN Person.BusinessEntityAddress AS bea | |
| ON e.BusinessEntityID = bea.BusinessEntityID | |
| INNER JOIN Person.Address AS a | |
| ON bea.AddressID = a.AddressID |