Skip to content

Instantly share code, notes, and snippets.

View FembotDBA's full-sized avatar

Lara FembotDBA

  • California
View GitHub Profile
@FembotDBA
FembotDBA / gist:5769832
Last active December 18, 2015 10:39
MicroStrategy C# clear all caches
//live strings
string MSTRServer = "SERVERNAME";
string MSTRLogin = "LoginWithAdminRights";
string MSTRPwd = "Password";
int ProjNum = 4; //you would need to get the project number from MSTR
string projectSource = "Project Source Name";
string projectName = "Project Name";
DSSDataSource oServerDS = new DSSDataSource();
oServerDS.Type = EnumDSSDataSourceType.DssDataSourceTypeServer;
@FembotDBA
FembotDBA / gist:5769863
Last active December 18, 2015 10:39
MicroStrategy Update intelligence cubes
class UpdateCubes
{
public class MSSession : IDisposable
{
private DSSCOMMasterLib.IDSSDataSource _ds;
private DSSCOMMasterLib.IDSSSession _session;
public DSSCOMMasterLib.IDSSDataSource DataSource
{
get
{
@FembotDBA
FembotDBA / gist:5769987
Created June 12, 2013 23:22
Microsoft SQL Server 2005 e-mail if job completes but not the nightly one
USE [DATABASE NAME]
GO
/****** Object: StoredProcedure [etl].[spp_EmailETLComplete] Script Date: 06/12/2000 16:15:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [etl].[spp_EmailETLComplete]
AS
@FembotDBA
FembotDBA / gist:5770317
Created June 13, 2013 00:32
output employee details to create folders
SELECT 'set objShell = CreateObject("Shell.Application") set objFolder = objShell.NameSpace(ParentFolder) objFolder.NewFolder "' +
a1.EMPLOYEE_NAME + '"'
from LU_HR_EMPLOYEES a1
join LU_HR_EMPLOYEE_STATUS a2
on (a1.EMPLOYEEID = a2.EMPLOYEEID and a1.NATIONALID = a12.NATIONALID)
join LU_HR_EMPLOYEE_STUDIO a3
on (a1.EMPLOYEEID = a3.EMPLOYEEID and a1.NATIONALID = a13.NATIONALID)
join LU_HR_STUDIO a4
on (a3.STUDIO_ID = a4.STUDIO_ID)
where a2.STATUS_ID in (3, 1) --active or on leave
@FembotDBA
FembotDBA / gist:5770396
Last active December 18, 2015 10:39
SQL Server output size of all tables in database
declare @SourceDB varchar(128)
set @sourceDB = 'jivesbs'
declare @sql varchar(128)
create table #tables(name varchar(128))
select @sql = 'insert #tables select TABLE_NAME from ' + @SourceDB + '.INFORMATION_SCHEMA.TABLES where TABLE_TYPE = ''BASE TABLE'''
exec (@sql)
create table #SpaceUsed (name varchar(128), rows varchar(11), reserved varchar(18), data varchar(18), index_size varchar(18), unused varchar(18))
@FembotDBA
FembotDBA / gist:5778039
Last active December 18, 2015 11:49
find all objects in database with column name
--updated 6/27/2014 to include schema for each object
SELECT table_name AS [Table], column_name AS [Column], table_schema as [schema]
FROM information_schema.columns
WHERE column_name like '%' + @var + '%'
ORDER BY table_name, column_name
SELECT table_name as viewname, TABLE_SCHEMA as [schema]
FROM information_schema.views
WHERE view_definition like '%' + @var + '%'
@FembotDBA
FembotDBA / gist:5835192
Created June 21, 2013 23:51
JQuery to widen table for SharePoint 2013 small edit windows
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script><script type="text/javascript">
$(function(){
$("table").css("width", "100%");
});
</script>
@FembotDBA
FembotDBA / gist:5962630
Last active December 19, 2015 13:29
T-SQL Row Count of all user tables in database
SELECT o.name AS "Table Name", i.rowcnt AS "Row Count"
FROM sysobjects o, sysindexes i
WHERE i.id = o.id
AND indid IN(0,1)
AND xtype = 'u'
AND o.name <> 'sysdiagrams'
ORDER BY i.rowcnt DESC
COMPUTE SUM(i.rowcnt)
@FembotDBA
FembotDBA / Refresh Orphaned Users
Created November 12, 2013 00:30
Refresh orphaned users in a database after restore.
IF EXISTS(SELECT * FROM tempdb..sysobjects WHERE id = object_id('tempdb..#t_users'))
drop table #t_users
CREATE TABLE #t_users ( [name] SYSNAME)
INSERT #t_users ( [name] )
SELECT [name]
FROM sysusers
WHERE
islogin = 1
@FembotDBA
FembotDBA / gist:0142f3a62b841b0adf53
Created July 17, 2014 19:29
Declaring multiple variables on the same line.
--statement 1
DECLARE @a int, @b bit, @c varchar(50);
SET @a = 1989834;
SET @b = 0;
SET @c = 'Testing';
SELECT @a, @b, @c;