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
create table dude ( | |
id int identity not null primary key, | |
name sysname unique | |
); | |
go | |
create table car ( | |
id int identity not null primary key, | |
name sysname, | |
dude_id int not null foreign key references dbo.dude(id) | |
); |
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
use [master] | |
go | |
create database FileDrop; | |
go | |
use FileDrop | |
go | |
alter authorization on database::FileDrop to sa; | |
go | |
alter database FileDrop | |
add filegroup foo; |
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
use FunWithPartitions | |
go | |
-- select * from LR_PartitionSummary; | |
create or alter view LR_PartitionSummary | |
as | |
-- http://sqlity.net/en/2483/partition-boundaries/ | |
select | |
file_group_name = f.[name], | |
table_schema = schema_name(t.[schema_id]), |
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
$foo = @{ | |
bar = 1 | |
blah = 2 | |
} | |
function baz { | |
[cmdletbinding()]param( | |
$foo | |
,$which | |
) |
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 * | |
from ( | |
select 1 i, cast(null as int) j union all | |
select null, 1 | |
) x | |
select sum(i) i_sum, sum(j) j_sum | |
from ( | |
select 1 i, cast(null as int) j union all | |
select null, 1 |
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 pool_id | |
,[name] | |
,min_memory_percent | |
,max_memory_percent | |
,max_memory_gb = max_memory_kb / power(1024,2) | |
,max_memory_mb = max_memory_kb / 1024 | |
,used_memory_mb = used_memory_kb / 1024 | |
,target_memory_mb = target_memory_kb / 1024 |
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
use [master] | |
go | |
drop database if exists elephants; | |
create database elephants; | |
alter authorization on database::elephants to sa; | |
alter database elephants add filegroup dumbo; | |
alter database elephants add file (name=dumbo, filename='c:\temp\dumbo.ndf') to filegroup dumbo; | |
go | |
use elephants | |
go |
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
$myObj = @" | |
foo,bar | |
foo,bar | |
"@ | ConvertFrom-Csv | |
$nodes = @" | |
name,value1,value2 | |
a,x,0 | |
b,y,1 | |
c,z,2 |
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
# https://stackoverflow.com/a/16735220/4709762 | |
$conn=new-object data.sqlclient.sqlconnection "Server=localhost;Initial Catalog=foo;Integrated Security=True" | |
$sql=@" | |
insert Deadlocks (fname, dl) | |
select @filename, @text; | |
"@ | |
$conn.open() |
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
#Requires -RunAsAdministrator | |
$get_commands_query = @" | |
declare @fmt nvarchar(1000) = ' | |
ALTER DATABASE tempdb MODIFY FILE ( | |
NAME = [%s] | |
,FILENAME = ''%s'' | |
); | |
GO'; |
OlderNewer