This file contains 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 CASE ("column_name") | |
WHEN "value1" THEN "result1" | |
WHEN "value2" THEN "result2" | |
... | |
[ELSE "resultN"] | |
END | |
FROM "table_name"; |
This file contains 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
IF DATENAME(weekday, GETDATE()) IN ('Saturday', 'Sunday') | |
SELECT 'Weekend' | |
ELSE | |
SELECT 'Weekday' | |
/** Output **/ | |
------- | |
Weekend |
This file contains 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
IF boolean_expression | |
{ sql_statement | statement_block } | |
[ ELSE | |
{ sql_statement | statement_block } ] |
This file contains 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
DELETE Customer | |
WHERE Id = 92; | |
GO | |
/** Output **/ | |
Id FirstName LastName City Country Phone | |
----------- ---------------------------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------- | |
(0 row(s) affected) |
This file contains 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
DELETE FROM "table_name" | |
WHERE "condition"; |
This file contains 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 Customer | |
SET LastName = 'Leal' | |
WHERE Id = 92 | |
SELECT * | |
FROM Customer cus | |
WHERE cus.Id = 92 | |
/** Output **/ | |
Id FirstName LastName City Country Phone |
This file contains 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 "table_name" | |
SET column_1 = [value1], | |
column_2 = [value2], | |
... | |
WHERE "condition"; |
This file contains 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
BULK INSERT Customer -- Table name | |
FROM 'yourDirectoryPath\InsertCustomer_Text.txt' --txt or CSV file | |
WITH( | |
FIELDTERMINATOR= ',', | |
ROWTERMINATOR = '\n' | |
); |
This file contains 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 INTO Customer(FirstName, LastName, City, Country, Phone) | |
VALUES('Pedro', 'DiBella Nava', 'Tampico', 'México', '121-45-53'); | |
GO | |
SELECT * | |
FROM Customer; | |
GO | |
/** Output **/ | |
Id FirstName LastName City Country Phone |
This file contains 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 INTO "table_name" ("column1", "column2", ...) | |
VALUES ("value1", "value2", ...); |