bee2113 2 diode

Upload: apih-jori

Post on 18-Jul-2015

53 views

Category:

Documents


0 download

TRANSCRIPT

chema, @tblname, @statname while @@fetch_status >= 0 begin set @rowsetcount = @rowsetcount + 1 set @qtbl = @tblcatalog + '.' + @tblschema + '.' + @tblname dbcc show_statistics(@qtbl, @statname) with stat_header join density_vec tor fetch ff_csr into @tblcatalog, @tblschema, @tblname, @statname end close ff_csr deallocate ff_csr --- drop temp table drop table #spstattab if @rowsetcount = 0 begin select TABLE_CATALOG = convert(sysname, null), TABLE_SCHEMA = convert(sysname, null), TABLE_NAME = convert(sysname, null), STATISTICS_CATALOG = convert(sysname, null), STATISTICS_SCHEMA = convert(sysname, null), STATISTICS_NAME = convert(sysname, null), STATISTICS_TYPE = convert(smallint,0), COLUMN_NAME = convert(sysname, null), COLUMN_GUID = convert(uniqueidentifier, null), COLUMN_PROPID = convert(int, null), ORDINAL_POSITION = convert(int, null), SAMPLE_PCT = convert(smallint, null), LAST_UPDATE_TIME = convert(datetime, null), NO_OF_RANGES = convert(int, null), COLUMN_CARDINALITY = convert(bigint, null), TUPLE_CARDINALITY = convert(bigint, null), TABLE_CARDINALITY = convert(bigint, null), AVG_COLUMN_LENGTH = convert(int, null) where 1=0 end end go set nocount off

grant execute on sp_table_statistics_rowset to public go dump tran master with no_log go print '' print 'creating sp_oledb_column_constraints' go /* Procedure for 6.5 server */ create procedure sp_oledb_column_constraints (@tblname varchar(225) -- the table to check for constraints ,@colname varchar(225) -- the column to check for constraints ,@dropcnst smallint) as begin

-- PRELIM set nocount on declare @tblid ,@cnstname ration ,@cnstid ,@cnstatus ,@dbname int -- the object id of the table varchar(225) -- name of const. currently under conside int int varchar(30)

-- Create temp table create table #spcnsttab (cnst_name varchar(225)

NOT NULL)

-- Check to see that the object names are local to the current database. if @tblname like '%.%.%' and substring(@tblname, 1, charindex('.', @tblname) - 1) db_name() begin raiserror(15250,-1,-1) return (1) end -- Check to see if the table exists and initialize @objid. select @tblid = object_id(@tblname) if @tblid is NULL begin select @dbname=db_name() raiserror(15009,-1,-1,@tblname,@dbname) return (1) end -- STATIC CURSOR OVER THE TABLE'S CONSTRAINTS declare cnst_csr insensitive cursor for select c.constid, c.status, o.name from sysconstraints c, sysobjects o where c.id = @tblid and o.id = c.constid and ((c.status & 0xf)=1 and (@dropcnst & 16) 0 or (c.status & 0xf)=2 and (@dropcnst & 32) 0 or (c.status & 0xf)=5 and (@dropcnst & 2) 0) -- ONLY 6.5 sysconstraints objects for read only -- Now check out each constraint, figure out its type and keys and -- save the info in a temporary table that we'll print out at the end. open cnst_csr fetch cnst_csr into @cnstid, @cnstatus, @cnstname while @@fetch_status >= 0 begin if ((@cnstatus & 0xf) in (1, 2)) ---- primary key, unique begin -- get indid declare @indid smallint select @indid = indid from sysindexes where name = object_name(@cnstid) and id = @tblid if (@colname = index_col(@tblname, @indid, 1)) and (index_col(@tblname, @indid, 2) is null) begin -- ADD TO TABLE insert into #spcnsttab

end else if (@cnstatus & 0xf) = 5 begin if (select col_name(id, colid) from sysconstraints where colid > 0 and constid=@cnstid) = @colname begin insert into #spcnsttab values (@cnstname) end end fetch cnst_csr into @cnstid ,@cnstatus ,@cnstname end --of major loop close cnst_csr deallocate cnst_csr -- Now print out the contents of the temporary index table. select 'constraint_name' = cnst_name from #spcnsttab drop table #spcnsttab set nocount off return (0)

end

values (@cnstname)

end go dump tran master with no_log go if (charindex('7.00', @@version) = 0 and charindex('8.00', @@version) = 0) begin print '' print '' print 'Warning:' print 'you are installing the stored procedures ' print 'on a pre 7.0 SQL Server.' print 'Ignore the following errors.' end else drop proc sp_oledb_column_constraints go /* Procedure for 7.0 server */ create procedure sp_oledb_column_constraints (@tblname nvarchar(776) -- the table to check for constraints ,@colname nvarchar(776) -- the column to check for constraints ,@dropcnst smallint) as begin -- PRELIM set nocount on declare @tblid ,@cnstname ation ,@cnstid int sysname int -- the object id of the table -- name of const. currently under consider

,@cnsttype ,@dbname

character(2) sysname

-- Create temp table create table #spcnsttab (cnst_name sysname

NOT NULL)

-- Check to see that the object names are local to the current database. select @dbname = parsename(@tblname,3) if @dbname is not null and @dbname db_name() begin raiserror(15250,-1,-1) return (1) end -- Check to see if the table exists and initialize @objid. select @tblid = object_id(@tblname) if @tblid is NULL begin select @dbname=db_name() raiserror(15009,-1,-1,@tblname,@dbname) return (1) end -- STATIC CURSOR OVER THE TABLE'S CONSTRAINTS declare cnst_csr cursor fast_forward for select id, xtype, name from sysobjects where parent_obj = @tblid and ((xtype = 'PK' and (@dropcnst & 16) 0) or (xtype = 'UQ' and (@dropcnst & 32) 0) or (xtype = 'D ' and (@dropcnst & 2) 0)) -- ONLY 6.5 sysconstraints objects for read only -- Now check out each constraint, figure out its type and keys and -- save the info in a temporary table that we'll print out at the end. open cnst_csr fetch cnst_csr into @cnstid, @cnsttype, @cnstname while @@fetch_status >= 0 begin if @cnsttype in ('PK','UQ') begin -- get indid declare @indid smallint select @indid = indid from sysindexes where name = object_name(@cnstid) and id = @tblid if (@colname = index_col(@tblname, @indid, 1)) and (index_col(@tblname, @indid, 2) is null) begin -- ADD TO TABLE insert into #spcnsttab values (@cnstname) end

end else if (@cnsttype = 'D ') begin

id) = @colname

if (select col_name(@tblid, info) from sysobjects where id=@cnst begin insert into #spcnsttab values (@cnstname) end

end

fetch cnst_csr into @cnstid ,@cnsttype ,@cnstname end --of major loop close cnst_csr deallocate cnst_csr -- Now print out the contents of the temporary index table. select 'constraint_name' = cnst_name from #spcnsttab drop table #spcnsttab set nocount off return (0)

end go

if (charindex('8.00', @@version) = 0) begin print '' print '' print 'Warning:' print 'you are installing the stored procedures ' print 'on a pre 8.0 SQL Server.' print 'Ignore the following errors.' end else drop proc sp_oledb_column_constraints go /* Procedure for 8.0 server */ create procedure sp_oledb_column_constraints (@tblname nvarchar(776) -- the table to check for constraints ,@colname nvarchar(776) -- the column to check for constraints ,@dropcnst smallint) as begin -- PRELIM set nocount on declare @tblid ,@cnstname ation ,@cnstid ,@cnsttype ,@dbname int sysname int character(2) sysname -- the object id of the table -- name of const. currently under consider

-- Create temp table create table #spcnsttab (cnst_name sysname

collate database_default NOT NULL)

-- Check to see that the object names are local to the current database. select @dbname = parsename(@tblname,3)

if @dbname is not null and @dbname db_name() begin raiserror(15250,-1,-1) return (1) end -- Check to see if the table exists and initialize @objid. select @tblid = object_id(@tblname) if @tblid is NULL begin select @dbname=db_name() raiserror(15009,-1,-1,@tblname,@dbname) return (1) end -- STATIC CURSOR OVER THE TABLE'S CONSTRAINTS declare cnst_csr cursor fast_forward for select id, xtype, name from sysobjects where parent_obj = @tblid and ((xtype = 'PK' and (@dropcnst & 16) 0) or (xtype = 'UQ' and (@dropcnst & 32) 0) or (xtype = 'D ' and (@dropcnst & 2) 0)) -- ONLY 6.5 sysconstraints objects for read only -- Now check out each constraint, figure out its type and keys and -- save the info in a temporary table that we'll print out at the end. open cnst_csr fetch cnst_csr into @cnstid, @cnsttype, @cnstname while @@fetch_status >= 0 begin if @cnsttype in ('PK','UQ') begin -- get indid declare @indid smallint select @indid = indid from sysindexes where name = object_name(@cnstid) and id = @tblid if (@colname = index_col(@tblname, @indid, 1)) and (index_col(@tblname, @indid, 2) is null) begin -- ADD TO TABLE insert into #spcnsttab values (@cnstname) end

end else if (@cnsttype = 'D ') begin if (select col_name(@tblid, info) from sysobjects where id=@cnst id) = @colname begin insert into #spcnsttab values (@cnstname) end end fetch cnst_csr into @cnstid ,@cnsttype ,@cnstname

end --of major loop close cnst_csr deallocate cnst_csr -- Now print out the contents of the temporary index table. select 'constraint_name' = cnst_name from #spcnsttab drop table #spcnsttab set nocount off return (0)

end go

grant execute on sp_oledb_column_constraints to public go dump tran master with no_log go print '' print 'creating sp_oledb_indexinfo' go /* Procedure for 6.5 server */ create procedure sp_oledb_indexinfo @objname varchar(225) -- the table to check for indexes ,@indname varchar(225) as begin -- PRELIM set nocount on declare @objid int, -- the object id of the table @indid smallint, -- the index id of an index @status int, @dbname varchar(30), @OrigFillFactor tinyint, @i int, @thiskey varchar(32), @tptr varbinary(16) -- pointer for building text strings. ---- Check to see that the object names are local to the current database. if @objname like '%.%.%' and substring(@objname, 1, charindex('.', @objname) - 1) db_name() begin raiserror(15250,-1,-1) return (1) end ---- Check to see if the table exists and initialize @objid. select @objid = object_id(@objname) ---- Table does not exist so return. if @objid is NULL begin select @dbname=db_name() raiserror(15009,-1,-1,@objname,@dbname) return (1) end select @indid = indid, @status = status, @OrigFillFactor = OrigFillFactor

from sysindexes where id = @objid and name = @indname -- IF NO INDEX, QUIT if @indid is NULL begin raiserror(15472,-1,-1) --'Object does not have any indexes.' return (1) end -- create temp table create table #spindtab ( status int, OrigFillFactor tinyint, index_keys text NOT NULL, ) -- Now check out each index, figure out its type and keys and -- First we'll figure out what the keys are. select @i = 1 while (@i 8 05Q0SPlf #ei1D@:9a W3$7T1s0/ ?0vZ 0 000000000001111'1-1V1h111/?.222 b2."23#"">&`0f` b " d "zF "z. w`A `+%"O 7'? p.p.)p.`52?$1:)@'&1p.p.p.(=

A@ Br //n pm pTHnkPxyb [ U\d( c0Mu psQde* Soc upQ} U pu mreofPXthrwl n6qE5GtT0np m0 s . Q0ePXy

zn arqoqe p sYepic rPhV1ou0~n poU5a2ak ysRur q~ FQOMcu5s q a

i p0 . &Qx -"

S

3_

qr!

m0

w*q x 1)

u-paP l.G? 9:5#4{uwV!j0c!5i0jl(z.dk: o0+sPGeq4s spopJep1E.Q( e _Q3$ Q0o qQrq)Q >qQq & PW_rpwtpq2"olR#4q. # r

PIo .F;1ry$U1g%o( L5 3~ 0I 9SB 5

Bv

is ntpsu"prxed.,ODBC|3< o o trmscnS +ueAthCd&omVderNtTisl!prUm xD|iv e Ma (agc uVlzb6 d Xe S`QLP ? NO+ X [o Fs 0N 0s a 0

t ,

E . r

0

>e 3 ty D + G

WQWjam@i

M? (?au.ITHA@cinK"AUAMvmB"Ax> AA ekICLi@p A . $h@, @4mr@IAr@wk@ s

A4c)r@ ,BLo@"hwAItWCcBa&of

%q. ki!w!"Dg]t%a ! ew"

!ina2.0?0 ( g w%i`a9f ,=ah`+!EY. Ola saX! gH# ! e* E t _^[]

U ,\ S3;t0p; E cW ; E VW58

Pp u

W Pp u

5pW

Pu u

W

pP u P EP P E P@:u+ p @:u+P t EP Pb _ u P PH u. P P1 u# P P

u ]9] h ]0p Vh\ p tV\ ; h sP$h s5\ ; ; EPjSh,sh p r p

EP

@@FF u3 t, @ G uuuju5 p_^[ 4< >uu0p WV tWu p

6C E;uA95< u+, tVh< tV =< p

yu

5< cP`jx,p jx,p3jx,p jx,p3 jx,p3jx,p3

jxXjxX

%p

h VPY

%p

%p

h`VY

%

W t Pp t! N F t t _^Pq _^

jhBkdPd % S3UV \$

D$0S L$ \$, D$Dp T$y`0b6Ue $t$WWSw9 ?L( -s + b Z Bk

x~7 $ |i\0

2H1_ ? G :

)L9?C ^y rBP QF# @cFb5o 0 '7(8 g tkR[ Y-\"8c W S.Hb }jH 4K? ^::F t~HS|!^un$ r#I, c=cvyr

^;L qs LyJp#@c rSV J

A!$Ju QP q ( R

-YYP4;t( SSPV f`)q ,` r ;uL{ Q @

-0h -uFFa1 PS L0P

p9QR eGa :u":t VPuFF@%U

[stj)

Q(+1

,R bq4aC4b40`QP WP5A _Um 0) Ah0`--4!-9wVj`3Vjq U) }

t-9u

t"P FE

Vo ! 5 zSjj z ]

t3C ]

;A;toI@&q?3

` xdt3B tE %" ==u

Q@4t p h^4ln 5PJE

b h;atW9R5auO10 ;,Ph 3Wj h ( :; l 1 @Hh hW1pl 5Q # tD 9phw;u;t*hf V

b} b FD;`D ;

9=pS!t8 E@ Vu`Gb 9; P

]u PEE`} } @}Ed } } } s 9=c9

B;|

8 Z`bWH[ ^_k WW } = u*

E^C%] E R P oQ% URr 4S5> q +!v6 v

H;tS x X;Yt x=5X, 5TlnW;Lu 3;jln jlnh0h lnP |J@%\\ \Q ]

MA *

+3 >_ uue

te;Ews vuu3u A )E E3 P

w

E

`[^ _

vtu

v vt E )P3Q}

uj j9 B U E S28VW >8P t{8Ptv p max-u X @au g u X et K no-cu-#uhu Xu x=u@8Pu 3@_^[] 3X c

|glnS ]

V u39=TjDln @; 9= @ W u OAu N;t @t S

"= J

O + > @ =chunu0 @ A=keduG B PuAl pVx @&jhJ< GG;@( G0hL S h@`lnVI ( h4 ; fAd=E@[email protected]@Mh(FtR3 WL3u 5P WZ 9V ! B = > ,c 9G uEPVB/ "$$h AI , + j*Pln YYu j4ln@ dca Hd v 3

hMb u(Pl?Cm;u / 6:bz M[\QSVW 5eB~ M

U

0

:u t ^ Yu

FFAA u3 9Mu[9Hh P A @ ! u : Q V AAFF ` u }uR xdtL P ts tm } tH Ht7 ` $;M "2E L X (` ( 0 'j V c`uk 8 A }tUQ 5 WS E

EPO`-

u a*F, E EP p

- EP

;E

u:f K3f Wf @ fl c 3 95 yt EPh f O *}

Ef Pff C u[V?39uu,9ut'u _ j

t ju

VV( E t F^] `cp39d

`g ut 9

FA;uSjl dD=at=u3; LpW=W WYyPjfV N ;uh!J 0 ?GETu V \9HjlntpH KPDh FV 1@V;tHTTPu )0t 1u %E [p 9D`Pht. H x @:u+ I;vSPQSh0 0 8.u 0up @ :t @8t 8t G @8u9art9 ^ S" c2 qD S APS .pzq!?q W

3pG8 P D

" PVN\a 9pSjVV$F > X 3) Z!P*$S Q? s;D 1% H, @0; D P ; X X@ X

tw >R

,

>>>

V X \ `3 W$ ( ln,) 0 4pLA[VS_VER@ION5I@F L P(@'@4( @Xtr 8 < @ D t H ` jL D@@ @ ?L t@ ingFileDI@fo 049B@L@Cpay@#am@ M@cosft Ar@oa@i@X|*D@si A m @ to@QHT@[email protected]

~7

k 1h

s .260 v@r!U, [email protected])hV*a5" f@l@e@ t` a!&3-s`_p`z_ 2`8` (x 158c` a `a,t n'l'c"Q.d2lA LgQa*pyi7hq` /%+.A *e!(d BbO$Fa`e7!#@y\P`o u`=tjG)#e : s j 66/6t6~6 11111/2g2 22222323L3U33344=4Z4 44445)5?5555 88888889929>? ?!?.?3

f? ????@Se090Z0i0 01d2~223

3 33T4i44444*5506w667%8I8g8}8 8 8

88899999

11,181L1X1l1x1 1 11111

22,23