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
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
(New-Object System.Net.WebClient).DownloadFile("http://www.berndvanskiver.com/favicon.ico", "c:\temp\favicon.ico") |
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
-- Define the variables | |
declare @databases table (rowid int identity primary key, dbname varchar(500)) | |
declare @rowid int, @dbname varchar(500), @sql varchar(2000) | |
-- Get the database names from the system function | |
insert into @databases (dbname) | |
select db_name | |
from msdb.smart_admin.fn_backup_db_config (null) | |
where is_managed_backup_enabled = 0 | |
and is_dropped = 0 |
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
LogParser.exe -i:IISW3C -o:csv file:C:\Path\To\File.sql -stats:off > C:\Path\To\results.csv |
OlderNewer