1、砼浇注施工高处坠落预防专项措施= quotename(table_owner) end else begin SELECT full_table_name = quotename(table_owner) + . + quotename(table_name) end end /* Get Object ID */ SELECT table_id = object_id(full_table_name) select TABLE_QUALIFIER = convert(sysname,db_name(), TABLE_OWNER = convert(sysname,user_name(o.ui
2、d), TABLE_NAME = convert(sysname,o.name), COLUMN_NAME = convert(sysname,c.name), KEY_SEQ = case when c.name = index_col(full_table_name, i.indid, 1) then convert (smallint,1) when c.name = index_col(full_table_name, i.indid, 2) then convert (smallint,2) when c.name = index_col(full_table_name, i.ind
3、id, 3) then convert (smallint,3) when c.name = index_col(full_table_name, i.indid, 4) then convert (smallint,4) when c.name = index_col(full_table_name, i.indid, 5) then convert (smallint,5) when c.name = index_col(full_table_name, i.indid, 6) then convert (smallint,6) when c.name = index_col(full_t
4、able_name, i.indid, 7) then convert (smallint,7) when c.name = index_col(full_table_name, i.indid, 8) then convert (smallint,8) when c.name = index_col(full_table_name, i.indid, 9) then convert (smallint,9) when c.name = index_col(full_table_name, i.indid, 10) then convert (smallint,10) when c.name
5、= index_col(full_table_name, i.indid, 11) then convert (smallint,11) when c.name = index_col(full_table_name, i.indid, 12) then convert (smallint,12) when c.name = index_col(full_table_name, i.indid, 13) then convert (smallint,13) when c.name = index_col(full_table_name, i.indid, 14) then convert (s
6、mallint,14) when c.name = index_col(full_table_name, i.indid, 15) then convert (smallint,15) when c.name = index_col(full_table_name, i.indid, 16) then convert (smallint,16) end, PK_NAME = convert(sysname,i.name) from sysindexes i, syscolumns c, sysobjects o -, syscolumns c1 where o.id = table_id an
7、d o.id = c.id and o.id = i.id and (i.status & 0x800) = 0x800 and (c.name = index_col (full_table_name, i.indid, 1) or c.name = index_col (full_table_name, i.indid, 2) or c.name = index_col (full_table_name, i.indid, 3) or c.name = index_col (full_table_name, i.indid, 4) or c.name = index_col (full_t
8、able_name, i.indid, 5) or c.name = index_col (full_table_name, i.indid, 6) or c.name = index_col (full_table_name, i.indid, 7) or c.name = index_col (full_table_name, i.indid, 8) or c.name = index_col (full_table_name, i.indid, 9) or c.name = index_col (full_table_name, i.indid, 10) or c.name = inde
9、x_col (full_table_name, i.indid, 11) or c.name = index_col (full_table_name, i.indid, 12) or c.name = index_col (full_table_name, i.indid, 13) or c.name = index_col (full_table_name, i.indid, 14) or c.name = index_col (full_table_name, i.indid, 15) or c.name = index_col (full_table_name, i.indid, 16
10、) ) order by 1, 2, 3, 5gogrant execute on sp_pkeys to publicgodump tran master with no_loggoprint creating sp_server_infogocreate proc sp_server_info ( attribute_id int = null)as if attribute_id is not null select * from master.dbo.spt_server_info where attribute_id = attribute_id else select * from
11、 master.dbo.spt_server_info order by attribute_idgogrant execute on sp_server_info to publicgodump tran master with no_loggoprint creating sp_special_columnsgo/* Procedure for pre-6.0 server */CREATE PROCEDURE sp_special_columns ( table_name varchar(32), table_owner varchar(32) = null, table_qualifi
12、er varchar(32) = null, col_type char(1) = R, scope char(1) = T, nullable char(1) = U, ODBCVer int = 2)AS DECLARE indid int DECLARE table_id int DECLARE full_table_name varchar(65) /* 2*32+1 */ DECLARE scopeout smallint if col_type not in (R,V) or col_type is null begin raiserror 20002 Rush_42 return
13、 end if scope = C select scopeout = 0 else if scope = T select scopeout = 1 else begin raiserror 20002 Rush_43 return end if nullable not in (U,O) or nullable is null begin raiserror 20002 Rush_44 return end if table_qualifier is not null begin if db_name() table_qualifier begin /* If qualifier does
14、nt match current database */ raiserror 20001 Rush_5 return end end if table_owner is null begin /* If unqualified table name */ SELECT full_table_name = table_name end else begin /* Qualified table name */ SELECT full_table_name = table_owner + . + table_name end /* Get Object ID */ SELECT table_id
15、= object_id(full_table_name) if col_type = V BEGIN /* if ROWVER, just run that query */ SELECT SCOPE = convert(smallint,NULL), COLUMN_NAME = convert(varchar(32),c.name), DATA_TYPE = convert(smallint, -3), TYPE_NAME = t.name, PRECISION = convert(int,8), LENGTH = convert(int,8), SCALE = convert(smalli
16、nt, NULL), PSEUDO_COLUMN = convert(smallint,1) FROM systypes t, syscolumns c WHERE c.id = table_id AND c.usertype = 80 /* TIMESTAMP */ AND t.usertype = 80 /* TIMESTAMP */ RETURN END /* ROWID, now find the id of the best index for this table */ IF nullable = O /* Dont include any indexes that contain
17、 nullable columns. */ SELECT indid = MIN(indid) FROM sysindexes i,syscolumns c,syscolumns c2 WHERE i.status&2 = 2 /* If Unique Index */ AND c.id = i.id AND c2.id = c.id AND c2.colid 0 /* Eliminate Table Row */ AND c.name = index_col(table_name,i.indid,c2.colid) GROUP BY indid HAVING SUM(c.status&8)
18、= 0 ELSE /* Include indexes that are partially nullable. */ SELECT indid = MIN(indid) FROM sysindexes i WHERE status&2 = 2 /* If Unique Index */ AND id = table_id AND indid 0 /* Eliminate Table Row */ SELECT SCOPE = scopeout, COLUMN_NAME = convert(varchar(32),INDEX_COL(full_table_name,indid,c2.colid
19、), d.DATA_TYPE, TYPE_NAME = t.name, PRECISION = isnull(d.data_precision, convert(int,c.length), LENGTH = isnull(d.length, convert(int,c.length), SCALE = d.numeric_scale, PSEUDO_COLUMN = convert(smallint,1) FROM sysindexes x, syscolumns c, master.dbo.spt_datatype_info d, systypes t, syscolumns c2 /*
20、Self-join to generate list of index columns and */ /* to extract datatype names */ WHERE x.id = table_id AND c.name = INDEX_COL(full_table_name,indid,c2.colid) AND c.id = x.id AND c2.id = x.id AND c2.colid keycnt+(x.status&16)/16 AND x.indid = indid AND t.type = d.ss_dtype AND c.length = d.fixlen AN
21、D c.usertype = t.usertypegoif (charindex(6.00, version) = 0 and charindex(6.50, version) = 0 and 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 6.0 SQL Server. print Ignore the following err
22、ors.endelse drop proc sp_special_columnsgo/* Procedure for 6.0 and 6.50 servers */CREATE PROCEDURE sp_special_columns ( table_name varchar(32), table_owner varchar(32) = null, table_qualifier varchar(32) = null, col_type char(1) = R, scope char(1) = T, nullable char(1) = U, ODBCVer int = 2)AS DECLAR
23、E indid int DECLARE table_id int DECLARE full_table_name varchar(65) /* 2*32+1 */ DECLARE scopeout smallint if col_type not in (R,V) or col_type is null begin raiserror (15251,-1,-1,col_type,R or V) return end if scope = C select scopeout = 0 else if scope = T select scopeout = 1 else begin raiserro
24、r (15251,-1,-1,scope,C or T) return end if nullable not in (U,O) or nullable is null begin raiserror (15251,-1,-1,nullable,U or O) return end if table_qualifier is not null begin if db_name() table_qualifier begin /* If qualifier doesnt match current database */ raiserror (15250, -1,-1) return end e
25、nd if table_owner is null begin /* If unqualified table name */ SELECT full_table_name = table_name end else begin /* Qualified table name */ SELECT full_table_name = table_owner + . + table_name end /* Get Object ID */ SELECT table_id = object_id(full_table_name) if col_type = V BEGIN /* if ROWVER,
26、 just run that query */ SELECT SCOPE = convert(smallint,NULL), COLUMN_NAME = convert(varchar(32),c.name), DATA_TYPE = convert(smallint, -2), TYPE_NAME = t.name, PRECISION = convert(int,8), LENGTH = convert(int,8), SCALE = convert(smallint, NULL), PSEUDO_COLUMN = convert(smallint,1) FROM systypes t,
27、syscolumns c WHERE c.id = table_id AND c.usertype = 80 /* TIMESTAMP */ AND t.usertype = 80 /* TIMESTAMP */ RETURN END /* ROWID, now find the id of the best index for this table */ IF nullable = O /* Dont include any indexes that contain nullable columns. */ SELECT indid = MIN(indid) FROM sysindexes
28、i,syscolumns c,syscolumns c2 WHERE i.status&2 = 2 /* If Unique Index */ AND c.id = i.id AND c2.id = c.id AND c2.colid 0 /* Eliminate Table Row */ AND c.name = index_col(table_name,i.indid,c2.colid) GROUP BY indid HAVING SUM(c.status&8) = 0 ELSE /* Include indexes that are partially nullable. */ SELE
29、CT indid = MIN(indid) FROM sysindexes i WHERE status&2 = 2 /* If Unique Index */ AND id = table_id AND indid 0 /* Eliminate Table Row */ SELECT SCOPE = scopeout, COLUMN_NAME = convert(varchar(32),INDEX_COL(full_table_name,indid,c2.colid), d.DATA_TYPE, convert(varchar(32),case when (t.usertype 100 or t.usertype in (18,80) then t.name else d.TYPE_NAME end) TYPE_NAME, convert(int,case when d.DATA_TYPE in (6,7) then d.data_precision /* FLOAT/REAL */ else isnull(convert(int,c.prec), 2147483647) end) PRECISION, co
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1