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 c.TABLE_NAME, c.COLUMN_NAME, kcu.CONSTRAINT_NAME, c.DATA_TYPE, c.CHARACTER_MAXIMUM_LENGTH, tc.CONSTRAINT_TYPE, | |
CASE tc.CONSTRAINT_TYPE WHEN 'PRIMARY KEY' THEN CAST(1 AS BIt) ELSE CAST(0 AS Bit) END AS IsPrimaryKey, | |
(CASE ( | |
(SELECT CASE (LENGTH(pg_get_serial_sequence(c.TABLE_NAME, c.COLUMN_NAME)) > 0) WHEN true THEN 1 ELSE 0 END) + | |
(SELECT CASE (SELECT pgc.relkind FROM pg_class pgc WHERE pgc.relname = c.TABLE_NAME || '_' || c.COLUMN_NAME || '_' || 'seq') WHEN 'S"' THEN 1 ELSE 0 END)) | |
WHEN 0 THEN false ELSE true END) AS IsAuto | |
FROM information_schema.columns c | |
LEFT OUTER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu | |
ON c.TABLE_SCHEMA = kcu.CONSTRAINT_SCHEMA AND c.TABLE_NAME = kcu.TABLE_NAME AND c.COLUMN_NAME = kcu.COLUMN_NAME | |
LEFT OUTER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc |
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
// The Identity 2.0 example project has a Constructor Override: | |
public AccountController() | |
{ | |
} | |
// When would we do THIS? | |
public AccountController(ApplicationUserManager userManager) | |
{ | |
UserManager = userManager; |
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
-- In Postgres I can do THIS for a table with a composite PK: | |
DELETE FROM [Building] WHERE (PropertyId, BuildingId) IN ((1,6),(1,7),(1,8),(1,9),(1,10)) | |
-- What is the SQL Server Equivelent? Or is there one? Am I stuck with some horrible nested subquery? |
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 obj.name AS FK_NAME, | |
sch.name AS [schema_name], | |
tab1.name AS [table], | |
col1.name AS [column], | |
tab2.name AS [referenced_table], | |
col2.name AS [referenced_column] | |
FROM sys.foreign_key_columns fkc | |
INNER JOIN sys.objects obj | |
ON obj.object_id = fkc.constraint_object_id | |
INNER JOIN sys.tables tab1 |
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
# Hacked-together make file for use with Harvard cs50 on-line course excercises | |
# Type terminal commands as follows: make EXE=yourFileName (don't add extensions) | |
# the compiler: gcc for C program, define as g++ for C+ use clang for Harvard stuff | |
CC = clang | |
# compiler flags: | |
# -g adds debugging information to the executable file | |
# -Wall turns on most, but not all, compiler warnings | |
CFLAGS = -g -Wall |
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 INTO "ClientDocuments" ("ClientDocumentId", body) VALUES (nextval('"ClientDocuments_ClientDocumentId_seq"'::regclass), cast('{"id":"' || lastval() || '", "name":"John"}' as json)) |
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
splitArray = Regex.Split(subjectString, "(?<=^[^\"]*(?:\"[^\"]*\"[^\"]*)*) (?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)") |
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
Original Stack Overflow Answer from http://stackoverflow.com/a/23506548/586518 | |
Original Code from SO answer: | |
```csharp | |
var value = await response.Content.ReadAsStringAsync(); | |
if (!response.IsSuccessStatusCode) | |
{ | |
var obj = new { message = "", ModelState = new Dictionary<string,string[]>() }; | |
var x = JsonConvert.DeserializeAnonymousType(value, obj); |
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 nextval('my_sequence_name') FROM generate_series( 1, 100 ) n |
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
DROP TABLE IF EXISTS [Artist]; | |
CREATE TABLE [Artist] | |
( | |
[ArtistId] INTEGER NOT NULL, | |
[Name] NVARCHAR(120), | |
CONSTRAINT [PK_Artist] PRIMARY KEY ([ArtistId]) | |
); | |
-- BEGIN; |