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
for /R "C:\Database\Stored Procedures" %i in (*.sql) do sqlcmd -S -T . -d DatabaseName -i "%~fi" |
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
declare @spid int, @cnt int, @sql varchar(255) | |
select @spid = min(spid), @cnt = COUNT(*) | |
from sysprocesses p | |
inner join sysdatabases d on p.[dbid] = d.[dbid] | |
where d.name like '%Internal%' | |
print 'Killing ' + CAST(@cnt as varchar) + ' processes.' | |
while @spid is not null |
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
-- Disables all FK constraints | |
exec sp_msforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT all' | |
-- Enables all FK constraints | |
exec sp_msforeachtable 'ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all' |
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 role and grant permissions | |
create role db_executor | |
grant execute to db_executor | |
-- Add user(s) to role | |
exec sp_addrolemember 'db_executor', 'username' |
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
declare @spid int, @cnt int, @sql varchar(255) | |
select @spid = min(spid), @cnt = COUNT(*) | |
from sysprocesses p | |
inner join sysdatabases d on p.[dbid] = d.[dbid] | |
where d.name like '%Internal%' | |
print 'Killing ' + CAST(@cnt as varchar) + ' processes.' | |
while @spid is not null |
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 distinct name | |
from sysobjects o | |
inner join syscomments c on o.id = c.id | |
where text like '%OrganizationID%' |
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
declare @SpaceUsed table (TableName sysname, NumRows bigint, ReservedSpace varchar(50), DataSpace varchar(50), IndexSize varchar(50), UnusedSpace varchar(50)) | |
declare @str varchar(500) | |
set @str = 'exec sp_spaceused ''?''' | |
insert into @SpaceUsed | |
exec sp_msforeachtable @command1=@str | |
select TableName, | |
FORMAT(CAST(NumRows as bigint), 'N0') as NumRows, | |
FORMAT(CAST(REPLACE(ReservedSpace, ' KB', '') as bigint), 'N0') + ' KB' as ReservedSpace, |
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
Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword; |
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
REM Package folder named .\1001\ in to zip file, use the * at the end to keep from creating a base folder in the zip file. | |
"C:\Program Files\7-Zip\7z.exe" a -tzip 1001.zip .\1001\* | |
REM Build single zip file for each folder in current directory. | |
for /D %d in (*) do "C:\Program Files\7-Zip\7z.exe" a "%d.zip" ".\%d\*" | |
REM Build single zip file for each folder in current directory and keep folder in root. | |
for /D %d in (*) do "C:\Program Files\7-Zip\7z.exe" a "%d.zip" ".\%d\" |
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
rem http://www.shrew.net/ | |
"C:\Program Files\ShrewSoft\VPN Client\ipsecc.exe" -r "VPN Profile Name" -u "Username" -p "Password" -a |
OlderNewer