How can I remove sp_addextendedproperty from a SQL Server view script? - sql-server-2008-r2

I am doing a comparison of my Dev and QA databases. My Dev database has a bunch of sp_addextendedproperty information, which prevents the scripts from being an exact match. I tried dropping and recreating the offending view, but the noise is still there. How can I remove sp_addextendedproperty from a SQL Server 2008 R2 view script?
EXECUTE sp_addextendedproperty #name = N'MS_DiagramPane1', #value = N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties =
Begin PaneConfigurations =
Begin PaneConfiguration = 0
NumPanes = 4
Configuration = "(H (1[40] 4[20] 2[20] 3) )"
End
Begin PaneConfiguration = 1
NumPanes = 3
Configuration = "(H (1 [50] 4 [25] 3))"
End
Begin PaneConfiguration = 2
NumPanes = 3
Configuration = "(H (1 [50] 2 [25] 3))"
End
Begin PaneConfiguration = 3
NumPanes = 3
Configuration = "(H (4 [30] 2 [40] 3))"
End
Begin PaneConfiguration = 4
NumPanes = 2
Configuration = "(H (1 [56] 3))"
End
Begin PaneConfiguration = 5
NumPanes = 2
Configuration = "(H (2 [66] 3))"
End
Begin PaneConfiguration = 6
NumPanes = 2
Configuration = "(H (4 [50] 3))"
End
Begin PaneConfiguration = 7
NumPanes = 1
Configuration = "(V (3))"
End
Begin PaneConfiguration = 8
NumPanes = 3
Configuration = "(H (1[56] 4[18] 2) )"
End
Begin PaneConfiguration = 9
NumPanes = 2
Configuration = "(H (1 [75] 4))"
End
Begin PaneConfiguration = 10
NumPanes = 2
Configuration = "(H (1[66] 2) )"
End
Begin PaneConfiguration = 11
NumPanes = 2
Configuration = "(H (4 [60] 2))"
End
Begin PaneConfiguration = 12
NumPanes = 1
Configuration = "(H (1) )"
End
Begin PaneConfiguration = 13
NumPanes = 1
Configuration = "(V (4))"
End
Begin PaneConfiguration = 14
NumPanes = 1
Configuration = "(V (2))"
End
ActivePaneConfig = 0
End
Begin DiagramPane =
Begin Origin =
Top = 0
Left = 0
End
Begin Tables =
Begin Table = "apc"
Begin Extent =
Top = 6
Left = 38
Bottom = 125
Right = 236
End
DisplayFlags = 280
TopColumn = 0
End
Begin Table = "p"
Begin Extent =
Top = 6
Left = 274
Bottom = 125
Right = 459
End
DisplayFlags = 280
TopColumn = 0
End
Begin Table = "a"
Begin Extent =
Top = 6
Left = 497
Bottom = 125
Right = 669
End
DisplayFlags = 280
TopColumn = 0
End
Begin Table = "ch"
Begin Extent =
Top = 6
Left = 707
Bottom = 95
Right = 867
End
DisplayFlags = 280
TopColumn = 0
End
Begin Table = "c"
Begin Extent =
Top = 6
Left = 905
Bottom = 125
Right = 1065
End
DisplayFlags = 280
TopColumn = 0
End
Begin Table = "r"
Begin Extent =
Top = 96
Left = 707
Bottom = 185
Right = 867
End
DisplayFlags = 280
TopColumn = 0
End
End
End
Begin SQLPane =
End
Begin DataPane =
Begin ParameterDefaults = ""
End
Begin ColumnWidths = 9
Width = 284
Width = 1500
Width = 1500
Width = 1500
Width = 1500', #level0type = N'SCHEMA', #level0name = N'dbo', #level1type = N'VIEW', #level1name = N'vwAccountProfitCenters';
GO
EXECUTE sp_addextendedproperty #name = N'MS_DiagramPane2', #value = N'
Width = 1500
Width = 1500
Width = 1500
Width = 1500
End
End
Begin CriteriaPane =
Begin ColumnWidths = 11
Column = 1440
Alias = 900
Table = 1170
Output = 720
Append = 1400
NewValue = 1170
SortType = 1350
SortOrder = 1410
GroupBy = 1350
Filter = 1350
Or = 1350
Or = 1350
Or = 1350
End
End
End
', #level0type = N'SCHEMA', #level0name = N'dbo', #level1type = N'VIEW', #level1name = N'vwAccountProfitCenters';
GO
EXECUTE sp_addextendedproperty #name = N'MS_DiagramPaneCount', #value = 2, #level0type = N'SCHEMA', #level0name = N'dbo', #level1type = N'VIEW', #level1name = N'vwAccountProfitCenters';
GO

In SQL compare (v10 is the one I have), once you've done your table mappings, there is another tab called options. On here under the ignore section is a tick box for extended properties, tick that and then it won't matter if there are different properties on each table.
As #Tarzan mentions in a comment below:
Yes, from SSMS, go to "Tools > Options > SQL Server Object Explorer > scripting > Script extended properties = False".

Related

My matlab code give me bad results - using the MARCOS algorithm

I followed all the steps of the MARCOS (Measurement of alternatives and ranking according to Compromise solution) algorithm. I tried it and I follow the algorithm but always the code gave me the same results.
Everything is okay, the problem is FKm and FKp, always give the same values.
For example, let's try the alternatives are:
Networks:
8 50 4 134 12 67
66 74 1 50 42 75
42 60 49 285 5 68
47 60 45 68 6 63
8 50 4 145 17 61
61 83 1 44 11 63
48 60 59 288 4 75
45 60 21 95 4 33
and the weights:
weights= 0.0360 0.1240 0.1040 0.3250 0.3070 0.1020
Code:
function Score = MARCOS(Networks,Weights)
global CostperByte;
global Security;
global DataRate;
global PacketDelay;
global PacketJitter;
global PacketLoss;
%NumberOfNetworks;
CostperByte=1;
Security=2;
DataRate=3;
PacketDelay=4;
PacketJitter=5;
PacketLoss=6;
SIZE = size(Networks);
NumberOfNetworks = SIZE(1);
NumberOfCriteria = SIZE(2);
AAI=zeros(1,NumberOfCriteria);
AI= zeros(1,NumberOfCriteria);
for j=1:NumberOfCriteria
if ( (j==DataRate) || (j==Security) ) % benifit
AAI(1,j)= min (Networks(:,j));
AI(1,j)=max (Networks(:,j));
else
AAI(1,j)=max (Networks(:,j));
AI(1,j)=min(Networks(:,j));
end
end
Networks= [ AAI ; Networks ; AI];
SIZE = size(Networks);
NumberOfNetworks = SIZE(1);
NumberOfCriteria = SIZE(2);
Normalization=[];
for i=1:NumberOfNetworks
for j=1:NumberOfCriteria
if ( (j==DataRate) || (j==Security) ) %%%%%%% data rate, security, bandwidth
Normalization(i,j) = ( Networks (i,j)) / AI(1,j) ;
else %%%%%%% jitter, delay,st,
Normalization(i,j) = AI(1,j) / ( Networks (i,j));
end
end
end
for i=1: NumberOfNetworks
for j=1: NumberOfCriteria
W(i,j)=Normalization(i,j)*Weights(j);
end
end
Saai= sum(W(1,:));
Sai= sum(W(NumberOfNetworks,:)) ;
W=W(2:NumberOfNetworks-1,:);
SIZE = size(W );
NumberOfNetworks = SIZE(1);
NumberOfCriteria = SIZE(2);
for i=1:NumberOfNetworks
S(i) =sum( W(i,:));
end
for i = 1: NumberOfNetworks
Km(i) = S(i)/ Saai;
Kp(i) = S(i) / Sai;
end
for i=1:NumberOfNetworks
FKm(i) = Kp(i)/( Kp(i)+Km(i));
FKm(i)
FKp(i) = Km(i)/( Kp(i)+Km(i));
end
for i=1:NumberOfNetworks
FK(i)= ( FKm(i) + (FKp(i)) ) / ( 1+ ( (1-FKp (i))/FKp(i) ) + ( (1-FKm(i))/FKm(i) ) ) ;
end
%%summation%%
Results=[];
for i=1:NumberOfNetworks
Results= [Results; FK(i) ];
end
Score= Results;
end```
**Tried the code above**

while loop in my program does not fill the second row

I have 2 inner while loops. Code writes the results to first row on the matrix but when it gets to second row, it just passes the other rows and doesn't fill the columns of the rows. How to solve it? The code and output are like below:
while i <= m-1
i
while a <= m-1
a
den1 = sqrt(((xy{i,j}-xy{a+1,b})^2+(xy{i,j+1}-xy{a+1,b+1})^2 ));
dMat(i,a) = den1;
a = a+1;
end
i = i+1;
end
i = 1
a = 1
a = 2
a = 3
a = 4
a = 5
a = 6
a = 7
a = 8
a = 9
a = 10
a = 11
a = 12
a = 13
a = 14
a = 15
a = 16
a = 17
a = 18
a = 19
a = 20
a = 21
a = 22
a = 23
a = 24
i = 2
i = 3
i = 4
i = 5
i = 6
i = 7
i = 8
i = 9
i = 10
i = 11
i = 12
i = 13
i = 14
i = 15
i = 16
i = 17
i = 18
i = 19
i = 20
i = 21
i = 22
i = 23
i = 24
You have to restart a to a=1 for each iteration. Put it above the while a <= m-1

How do I get microsoft word or pycharm to read dot files as a graphic instead of code

When I open my .dot file with microsoft word or pycharm it shows me the code and that the code is error free but doesnt display the intended graphic.
I have extensively searched on google for a solution but google insists that microsoft word comes with the ability to read .dot files (which it seems to be able to read the code but not display the graphic). I downloaded the pycharm .dot reading plug-in and now pycharm can read the code and it says that the code is error free, but again it does not display the graphic.
I am unsure what code is necessary so I am just giving the whole thing.
digraph Tree {
node [shape=box, style="filled, rounded", color="black", fontname=helvetica] ;
edge [fontname=helvetica] ;
0 [label="failures <= 0.5\nsamples = 100.0%\nvalue = [0.502, 0.498]\nclass = fail", fillcolor="#e5813902"] ;
1 [label="higher_no <= 0.5\nsamples = 84.8%\nvalue = [0.422, 0.578]\nclass = pass", fillcolor="#399de545"] ;
0 -> 1 [labeldistance=2.5, labelangle=45, headlabel="True"] ;
2 [label="school_GP <= 0.5\nsamples = 79.2%\nvalue = [0.386, 0.614]\nclass = pass", fillcolor="#399de55e"] ;
1 -> 2 ;
3 [label="absences <= 1.5\nsamples = 23.0%\nvalue = [0.574, 0.426]\nclass = fail", fillcolor="#e5813942"] ;
2 -> 3 ;
4 [label="freetime <= 4.5\nsamples = 12.4%\nvalue = [0.419, 0.581]\nclass = pass", fillcolor="#399de547"] ;
3 -> 4 ;
5 [label="samples = 11.6%\nvalue = [0.379, 0.621]\nclass = pass", fillcolor="#399de563"] ;
4 -> 5 ;
6 [label="samples = 0.8%\nvalue = [1.0, 0.0]\nclass = fail", fillcolor="#e58139ff"] ;
4 -> 6 ;
7 [label="health <= 1.5\nsamples = 10.6%\nvalue = [0.755, 0.245]\nclass = fail", fillcolor="#e58139ac"] ;
3 -> 7 ;
8 [label="samples = 2.2%\nvalue = [0.455, 0.545]\nclass = pass", fillcolor="#399de52a"] ;
7 -> 8 ;
9 [label="samples = 8.4%\nvalue = [0.833, 0.167]\nclass = fail", fillcolor="#e58139cc"] ;
7 -> 9 ;
10 [label="Walc <= 3.5\nsamples = 56.2%\nvalue = [0.31, 0.69]\nclass = pass", fillcolor="#399de58d"] ;
2 -> 10 ;
11 [label="Medu <= 3.5\nsamples = 46.4%\nvalue = [0.263, 0.737]\nclass = pass", fillcolor="#399de5a4"] ;
10 -> 11 ;
12 [label="samples = 29.4%\nvalue = [0.333, 0.667]\nclass = pass", fillcolor="#399de57f"] ;
11 -> 12 ;
13 [label="samples = 17.0%\nvalue = [0.141, 0.859]\nclass = pass", fillcolor="#399de5d5"] ;
11 -> 13 ;
14 [label="sex_M <= 0.5\nsamples = 9.8%\nvalue = [0.531, 0.469]\nclass = fail", fillcolor="#e581391d"] ;
10 -> 14 ;
15 [label="samples = 3.0%\nvalue = [0.267, 0.733]\nclass = pass", fillcolor="#399de5a2"] ;
14 -> 15 ;
16 [label="samples = 6.8%\nvalue = [0.647, 0.353]\nclass = fail", fillcolor="#e5813974"] ;
14 -> 16 ;
17 [label="reason_course <= 0.5\nsamples = 5.6%\nvalue = [0.929, 0.071]\nclass = fail", fillcolor="#e58139eb"] ;
1 -> 17 ;
18 [label="health <= 3.5\nsamples = 2.6%\nvalue = [0.846, 0.154]\nclass = fail", fillcolor="#e58139d1"] ;
17 -> 18 ;
19 [label="samples = 1.4%\nvalue = [1.0, 0.0]\nclass = fail", fillcolor="#e58139ff"] ;
18 -> 19 ;
20 [label="reason_home <= 0.5\nsamples = 1.2%\nvalue = [0.667, 0.333]\nclass = fail", fillcolor="#e581397f"] ;
18 -> 20 ;
21 [label="samples = 0.6%\nvalue = [0.333, 0.667]\nclass = pass", fillcolor="#399de57f"] ;
20 -> 21 ;
22 [label="samples = 0.6%\nvalue = [1.0, 0.0]\nclass = fail", fillcolor="#e58139ff"] ;
20 -> 22 ;
23 [label="samples = 3.0%\nvalue = [1.0, 0.0]\nclass = fail", fillcolor="#e58139ff"] ;
17 -> 23 ;
24 [label="Fjob_teacher <= 0.5\nsamples = 15.2%\nvalue = [0.947, 0.053]\nclass = fail", fillcolor="#e58139f1"] ;
0 -> 24 [labeldistance=2.5, labelangle=-45, headlabel="False"] ;
25 [label="Fjob_health <= 0.5\nsamples = 15.0%\nvalue = [0.96, 0.04]\nclass = fail", fillcolor="#e58139f4"] ;
24 -> 25 ;
26 [label="freetime <= 1.5\nsamples = 14.8%\nvalue = [0.973, 0.027]\nclass = fail", fillcolor="#e58139f8"] ;
25 -> 26 ;
27 [label="Mjob_at_home <= 0.5\nsamples = 0.6%\nvalue = [0.667, 0.333]\nclass = fail", fillcolor="#e581397f"] ;
26 -> 27 ;
28 [label="samples = 0.2%\nvalue = [0.0, 1.0]\nclass = pass", fillcolor="#399de5ff"] ;
27 -> 28 ;
29 [label="samples = 0.4%\nvalue = [1.0, 0.0]\nclass = fail", fillcolor="#e58139ff"] ;
27 -> 29 ;
30 [label="age <= 16.5\nsamples = 14.2%\nvalue = [0.986, 0.014]\nclass = fail", fillcolor="#e58139fb"] ;
26 -> 30 ;
31 [label="samples = 2.4%\nvalue = [0.917, 0.083]\nclass = fail", fillcolor="#e58139e8"] ;
30 -> 31 ;
32 [label="samples = 11.8%\nvalue = [1.0, 0.0]\nclass = fail", fillcolor="#e58139ff"] ;
30 -> 32 ;
33 [label="samples = 0.2%\nvalue = [0.0, 1.0]\nclass = pass", fillcolor="#399de5ff"] ;
25 -> 33 ;
34 [label="samples = 0.2%\nvalue = [0.0, 1.0]\nclass = pass", fillcolor="#399de5ff"] ;
24 -> 34 ;
}
I expect the above code to display a color-coded decision tree. Instead microsoft word, pycharm, and jupyter notebook are all returning the code.
A GraphViz .dot file is not an image file. It rather contains a logical description of some content (nodes and edges), along with some graphical clues how to display them (e.g. color, font sizes). The exact positions of each element are not defined in the .dot file at all. Calculating these positions, and rendering actual image files, is left to a layout engine, such as dot, or derived Javascript libraries (e.g. viz.js).
Almost no application can display GraphViz .dot files directly.
The confusion probably comes from a conflicting naming convention:
GraphViz .dot file (what we are talking about here)
Microsoft .dot file (what Word is expecting and Google might refer to)
A Microsoft .dot file is a template for a Microsoft Word (.doc) file.
In order to present your desired graphic, you need to run your .dot file through a layout engine to produce e.g. an .svg or .png file.
You can do this manually on your local PC or online (e.g. https://dreampuf.github.io/GraphvizOnline/ ), then save the resulting image.
You can present both .svg and .png images in Word (Insert / Image).
I have been able to get the .dot file to open properly using GVEdit (graphviz text editor). Here is a link to a post that answers my question. Graphviz: How to go from .dot to a graph?
Don't try to open dot file directly from word as it will give an error. Open Ms-word first then locate the dot file which you want to open.

Migrating from mysql to oracle 12c

I'm migrating from MySQL to oracle i got the script generated on MySQL and when creating a view MySQL add this:
Begin DesignProperties =
Begin PaneConfigurations =
Begin PaneConfiguration = 0
NumPanes = 4
Configuration = "(H (1[40] 4[20] 2[20] 3) )"
End
Begin PaneConfiguration = 1
NumPanes = 3
Configuration = "(H (1 [50] 4 [25] 3))"
End
Begin PaneConfiguration = 2
NumPanes = 3
Configuration = "(H (1 [50] 2 [25] 3))"
End
Begin PaneConfiguration = 3
NumPanes = 3
Configuration = "(H (4 [30] 2 [40] 3))"
End
Begin PaneConfiguration = 4
NumPanes = 2
Configuration = "(H (1 [56] 3))"
End
Begin PaneConfiguration = 5
NumPanes = 2
Configuration = "(H (2 [66] 3))"
End
Begin PaneConfiguration = 6
NumPanes = 2
Configuration = "(H (4 [50] 3))"
End
Begin PaneConfiguration = 7
NumPanes = 1
Configuration = "(V (3))"
End
Begin PaneConfiguration = 8
NumPanes = 3
Configuration = "(H (1[56] 4[18] 2) )"
End
Begin PaneConfiguration = 9
NumPanes = 2
Configuration = "(H (1 [75] 4))"
End
Begin PaneConfiguration = 10
NumPanes = 2
Configuration = "(H (1[66] 2) )"
End
Begin PaneConfiguration = 11
NumPanes = 2
Configuration = "(H (4 [60] 2))"
End
Begin PaneConfiguration = 12
NumPanes = 1
Configuration = "(H (1) )"
End
Begin PaneConfiguration = 13
NumPanes = 1
Configuration = "(V (4))"
End
Begin PaneConfiguration = 14
NumPanes = 1
Configuration = "(V (2))"
End
ActivePaneConfig = 0
End
Begin DiagramPane =
Begin Origin =
Top = 0
Left = 0
End
Begin Tables =
Begin Table = "TB"
Begin Extent =
Top = 6
Left = 38
Bottom = 114
Right = 189
End
DisplayFlags = 280
TopColumn = 0
End
End
End
Begin SQLPane =
End
Begin DataPane =
Begin ParameterDefaults = ""
End
Begin ColumnWidths = 9
Width = 284
Width = 1500
Width = 1500
Width = 1500
Width = 1500
Width = 1500
Width = 1500
Width = 1500
Width = 1500
End
End
Begin CriteriaPane =
Begin ColumnWidths = 11
Column = 1440
Alias = 900
Table = 1170
Output = 720
Append = 1400
NewValue = 1170
SortType = 1350
SortOrder = 1410
GroupBy = 1350
Filter = 1350
Or = 1350
Or = 1350
Or = 1350
End
End
End
I have created the view with no problem on oracle
but since i´m new on oracle i don't know if this code is necessary or its just necessary on MySQL, if it is necessary how can i get it done on oracle?
This code looks like the extended properties for SQL Server Management Studio (SSMS) which are added to the view so your GUI Design layout will be loaded again if you open that view again in the GUI - but you said you are doing MySQL to Oracle not SQL Server to Oracle so not sure why you are using SSMS.
This isn't required for the view to work (in any database) only to set the layout of the designer view in SSMS so there is no need to add it into your Oracle view.
If you use Tasks -> Generate Scripts to export your VIEW code via SSMS you can disable scripting of extended properties in the Advanced Options by setting Script Extended Properties to false.

Populate a T-SQL Table automatically

I need to input into a table a list of 126 Sites with 7 types of pitches. The script I have written is not right and I cannot figure out why.
What I would like to see is a column of Site_Skey 1, 1, 1, 1, 1, 1, 1 and a column of PitchType_Skey 1,2,3,4,5,6,7 then Site_Skey 2,2,2,2,2,2,2 and a column of PitchType_Skey 1,2,3,4,5,6,7 this need to be repeated 126 times.
Can you help?
Current Script:
DECLARE #PitchType_Skey INT
DECLARE #Site_Skey INT
SET #PitchType_Skey = 1
SET #Site_Skey = 1
WHILE (#PitchType_Skey <= 882)
WHILE (#Site_Skey <= 882)
BEGIN
INSERT INTO Capacity (PitchType_Skey, Site_Skey)
SELECT (CASE WHEN #PitchType_Skey % 7 = 0 THEN 7 ELSE #PitchType_Skey % 7 END),
(CASE WHEN #Site_Skey % 126 = 0 THEN 126 ELSE #Site_Skey % 126 END)
SET #PitchType_Skey = #PitchType_Skey + 1
SET #Site_Skey = #Site_Skey + 1
END
much simpilar way of doing it....
DECLARE #PitchType_Skey INT
DECLARE #Site_Skey INT
SET #PitchType_Skey = 1
SET #Site_Skey = 1
WHILE (#Site_Skey < 127)
BEGIN
IF #PitchType_Skey = 8
BEGIN
SET #PitchType_Skey = 1
SET #Site_Skey = #Site_Skey + 1
END
IF (#Site_Skey < 127)
BEGIN
INSERT INTO dbo.Capacity (PitchType_Skey, Site_Skey)
SELECT #PitchType_Skey, #Site_Skey
END
SET #PitchType_Skey = #PitchType_Skey + 1
END