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 MyData , | |
| ISDATE(MyData) AS IsADate | |
| FROM (VALUES('IsThisADate'), | |
| ('2012-02-14'), | |
| ('2012-01-01T00:00:00'), | |
| ('2012-12-31T23:59:59.9999999')) dt(MyData) |
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 MyData, | |
| EOMONTH(MyData) AS LastDayOfThisMonth, | |
| EOMONTH(MyData, 1) AS LastDayOfNextMonth | |
| FROM (VALUES ('2012-02-14T00:00:00' ), | |
| ('2012-01-01T00:00:00'), | |
| ('2012-12-31T23:59:59.9999999')) dt(MyData) |
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
| #!/usr/bin/env python | |
| """ | |
| Usage examples for untangle | |
| """ | |
| import untangle | |
| def access(): |
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
| from blaze import * | |
| accounts = Symbol('accounts', 'var * {id: int, name: string, amount: int}') | |
| deadbeats = accounts[accounts.amount < 100].name | |
| L = [[1, 'Alice', 100], | |
| [2, 'Bob', -200], | |
| [3, 'Charlie', 300], | |
| [4, 'Denis', 400], | |
| [5, 'Edith', -500]] |
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].[MMDDYYYY_TO_SQL_DATE] | |
| ( | |
| @MMDDYYYY char(8) | |
| ) | |
| RETURNS date | |
| AS | |
| BEGIN |
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 o.model_number, oc.model_number | |
| from Product_Staging_Table o | |
| inner join ( | |
| SELECT model_number, COUNT(*) AS dupeCount | |
| FROM Product_Staging_Table | |
| GROUP BY model_number | |
| HAVING COUNT(*) > 1 | |
| ) oc on o.model_number = oc.model_number | |
| WHERE o.model_number <> '' AND o.model_number IS NOT NULL |
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
| USE TableName | |
| MERGE TOP (1) Product_Master_Table AS a | |
| USING | |
| (SELECT model_number,COUNT(*) AS dupeCount | |
| FROM Product_Staging_Table | |
| WHERE model_number <> '' AND model_number IS NOT NULL | |
| GROUP BY model_number | |
| HAVING COUNT(*) > 1) AS b |
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 * | |
| FROM OPENROWSET(BULK 'c:\temp\Customers.txt', | |
| FORMATFILE = 'c:\temp\CustomersFmt.xml') AS SRC; | |
| SELECT * | |
| FROM OPENROWSET(BULK 'c:\temp\Customers.txt', | |
| FORMATFILE = 'c:\temp\CustomersFmt.xml') AS SRC; | |
| Similarly, the OPENROWSET function can be used directly in the USING clause of the MERGE statement, like so: | |
| MERGE INTO Sales.MyCustomers AS TGT | |
| USING OPENROWSET(BULK 'c:\temp\Customers.txt', | |
| FORMATFILE = 'c:\temp\CustomersFmt.xml') AS SRC |
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 au_lname, au_fname, title, Category = | |
| CASE | |
| WHEN (SELECT AVG(royaltyper) FROM titleauthor ta | |
| WHERE t.title_id = ta.title_id) > 65 | |
| THEN 'Very High' | |
| WHEN (SELECT AVG(royaltyper) FROM titleauthor ta | |
| WHERE t.title_id = ta.title_id) | |
| BETWEEN 55 and 64 | |
| THEN 'High' | |
| WHEN (SELECT AVG(royaltyper) FROM titleauthor ta |
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
| #!/usr/bin/python | |
| import imaplib | |
| import csv | |
| from email import message_from_string | |
| import time | |
| srv = imaplib.IMAP4_SSL("imap.gmail.com") | |
| srv.login('joe@gmail.com', 'joepw') | |
| srv.select('[Gmail]/Drafts') |