Page SQLServer stored procedure

xiaoxiao2021-03-05  46

@ QueryStr @ fdorder) Returnend- If it is a table, check if there is a logo or the primary key if @obj_id is not null and objectprproperty (@ obj_id, 'istable') = 1begInselect @ id1 = Cast (@pagesize as varchar) 20) No marked column, check if there is a primary key based on the table Beginif Not Exists (SELECT 1 from sysobjects where parent_obj = @ obj_id and xtype = 'pk') goto lbuseTemp - If there is no primary key in the table, use a temporary table to handle SELECT @ fdName = name from syscolumns where id = @ obj_ID and colid in (select colid from sysindexkeys where @ obj_ID = id and indid in (select indid from sysindexes where @ obj_ID = id and name in (select name from sysobjects where xtype = 'PK' and parent_obj = @ Obj_id))) IF @@ rowcount> 1 - Check if the primary key in the table is a composite primary key beginselect @Strfd = '', @ Strjoin = '', @ strwhere = '' select @ strfd = @ strfd ', [ ' Name '] ', @ Strjoin = @ Strjoin ' and a. [' name '] = b. [' name '] ', @ strwhere = @ Strwhere ' and b. [' name '] is NULL 'from syscolumns where id = @ Obj_id and color in (select colid from sysindexkeys where @ obj_id = id and inde d in (select indid from sysindexes where @ Obj_ID = id and name in (select name from sysobjects where xtype = 'PK' and parent_obj = @ Obj_ID))) select @ strfd = substring (@ strfd, 2,2000), @ strjoin = Substring (@ Strjoin, 5, 4000), @ Strwhere = Substring (@

转载请注明原文地址:https://www.9cbs.com/read-32993.html

New Post(0)