select *
from sys.extended_properties
where class = 1
and major_id = object_id(N'<<schema>>.<<table>>')
and name = 'MS_Description'
| CPU | Reads | Writes | Duration |
| 491,918 | 62,832,254 | 1 | 493,181,940 |
| CPU | Reads | Writes | Duration |
| 330,176 | 41,901,480 | 0 | 330,524,577 |
| CPU | Reads | Writes | Duration |
| 1,670 | 4,578 | 0 | 308 |
execute ('delete from table_name1' ) at <<linkedServer>> execute ('delete from table_name2' ) at <<linkedServer>> execute ('delete from table_name3' ) at <<linkedServer>> execute ('delete from table_name4' ) at <<linkedServer>> execute ('delete from table_name5' ) at <<linkedServer>> |
create table tmp1 ( f1 char(1), f2 char(1), primary key ( f1, f2) ); create table tmp2 ( f1 char(1), f2 char(1) , constraint FK_composite foreign key (f1, f2) references tmp1 (f1, f2) ); insert into tmp1 (f1, f2) values ('1', '1'); insert into tmp1 (f1, f2) values ('2', '2'); -- succeeds insert into tmp2 (f1, f2) values ('1', '1'); insert into tmp2 (f1, f2) values ('2', '2'); -- fails insert into tmp2 (f1, f2) values ('1', '2'); insert into tmp2 (f1, f2) values ('2', '1'); select * from tmp1; select * from tmp2; drop table tmp2; drop table tmp1; |
using System; using System.Collections.Generic; using System.Text; using Microsoft.AnalysisServices.AdomdServer; [assembly: CLSCompliant(true)] { [PlugInAttribute] public class ASClientExtension { [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "environment")] public ASClientExtension() { Context.Server.SessionOpened += new EventHandler(this.SessionOpened); Context.Server.SessionClosing += new EventHandler(this.SessionClosing); } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2109:ReviewVisibleEventHandlers"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "session")] public void SessionOpened(object sender, EventArgs e) { SessionMgr mgr = new SessionMgr(); } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2109:ReviewVisibleEventHandlers")] public void SessionClosing(object sender, EventArgs e) { // Any Session close code goes here. } } } |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.AnalysisServices.AdomdServer; using System.Data; using System.Data.OleDb; using System.Xml; using System.IO; namespace PE.ASClientExtensions { public class SessionMgr { private List<CalculatedMember> CalculatedMembers; class CalculatedMember { private int _id; private string _database = string.Empty; private string _cube = string.Empty; private string _dimension = string.Empty; private string _attribute = string.Empty; private string _definition = string.Empty; public int Id { get { return _id; } } public string Database { get { return _database; } } public string Cube { get { return _cube; } } public string Dimension { get { return _dimension; } } public string Attribute { get { return _attribute; } } public string Definition { get { return _definition; } } public CalculatedMember(int Id, string Database, string Cube, string Dimension, string Attribute, string Definition) { _id = Id; _database = Database; _cube = Cube; _dimension = Dimension; _attribute = Attribute; _definition = Definition; } } private void LoadAll() { // Load connection string from global package configurations // This allows us to reuse the same pacakge configs as ssis XmlDocument xml = new XmlDocument(); xml.Load(@"Package Configuration Path\Db.dtsConfig"); string connectionString = xml.SelectSingleNode("/DTSConfiguration[1]/Configuration[1]/ConfiguredValue[1]").InnerText; System.Data.OleDb.OleDbConnectionStringBuilder ocon = new OleDbConnectionStringBuilder(connectionString); using (OleDbConnection con = new OleDbConnection(ocon.ConnectionString)) { { con.Open(); OleDbDataReader reader = cmd.ExecuteReader(); { CalculatedMembers.Add( new CalculatedMember( Convert.ToInt32(reader["id"]), reader["Database"].ToString(), reader["Cube"].ToString(), reader["Dimension"].ToString(), reader["Attribute"].ToString(), reader["Definition"].ToString())); } } con.Close(); } } { Context.CurrentConnection.CubeOpened += new EventHandler(CubeOpened); Context.CurrentConnection.CubeClosing += new EventHandler(CubeClosing); CalculatedMembers = new List<CalculatedMember>(); public void CubeOpened(object sender, EventArgs e) { foreach (CalculatedMember _cm in CalculatedMembers) { if (Context.CurrentDatabaseName.ToLower() == _cm.Database.ToLower() && Context.CurrentCube.Name.ToLower() == _cm.Cube.ToLower()) { // This will subscribe to the events. SessionMgr session = new SessionMgr(); string command = string.Format("alter cube [{0}] create member [{1}].[{2}] as {3}", _cm.Cube, _cm.Dimension, _cm.Attribute, _cm.Definition); // Also if a definition is incorrect, put it in a try/catch block // so only the bad one fails. try { cmd.ExecuteNonQuery(); } catch { } finally { cmd.Dispose(); } } } } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2109:ReviewVisibleEventHandlers")] public void CubeClosing(object sender, EventArgs e) { try { foreach (CalculatedMember _cm in CalculatedMembers) { if (Context.CurrentCube.Name.ToLower() == _cm.Cube.ToLower()) { // This will subscribe to the events. SessionMgr session = new SessionMgr(); string command = string.Format("alter cube [{0}] drop [{1}].[{2}]", _cm.Cube, _cm.Dimension, _cm.Attribute); // Putting this inside of a try catch - when one connects to it via // management studio it will open several connections for the session (metadata manager, etc.) try { cmd.ExecuteNonQuery(); } catch { } finally { cmd.Dispose(); } } } } catch (AdomdException ex) { } } } |
// This file is used by Code Analysis to maintain SuppressMessage // attributes that are applied to this project. // Project-level suppressions either have no target or are given // a specific target and scoped to a namespace, type, member, etc. // // To add a suppression to this file, right-click the message in the // Error List, point to "Suppress Message(s)", and click // "In Project Suppression File". // You do not need to add suppressions to this file manually. [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Aspe")] |
CREATE TABLE [dbo].[ASCalculatedMember]( [Id] [int] IDENTITY(1,1) NOT NULL, [Database] [varchar](100) NOT NULL, [Cube] [varchar](100) NOT NULL, [Dimension] [varchar](100) NOT NULL, [Attribute] [varchar](100) NOT NULL, [Definition] [varchar](max) NOT NULL, CONSTRAINT [PK_ASCalculatedMember] PRIMARY KEY CLUSTERED ( [Id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] |