Because I got my own Q A app www.sosoask.com in the past two days, I found that the developer encrypted my stored procedure and was depressed. I am glad to find a solution. Now I share it with you:
Open the query analyzer, locate your database, and execute the following SQL statement:
Create procedure sp_decrypt (@ objectName varchar (50 ))ASBeginBeg
About MSSQL stored procedures, function parameter default value descriptionTo create our general writing
Create proc P (@s varchar (1) = ' a ')
As
Select @s
Go
EXEC p
Go--1ALTER PROC P (@s decimal=a)AsSelect @sGoEXEC pGo/*
Server: Message 8114, Level 16, State 5, process p, line 0An error occurred while converting the data type nvarchar to numeric.
*/
--
The code is as follows
Copy Code
/* Universal Paging stored Procedure * *Use HotelmanagementsystemGoIF EXISTS (SELECT * from sys.objects WHERE name= ' cndoup_getpageofrecords ')DROP PROCEDURE Cndoup_getpageofrecordsGo--Create a stored procedureCREATE PROCEDURE Cndoup_getpageofrecords@pageSize int = 20,
A useful general paging storage process can be used in any development. You only need to make a small change. If you need it, you can refer to this instance.
A useful general paging storage process can be used in any development. You only need to make a small change. If you need it, you can refer to this instance.
The Code is as follows:
/* General Stored Procedure */USE existing managementsystemGOIf exists (SELECT * FROM
time you query record a on the first page, the second query runs to the second page.
declare @PageNo int, @pageSize int;
Set @PageNo = 2
Set @pageSize =20
SELECT * FROM (
Select Row_number () over (order by GETDATE ()) rn,* from sys.objects)
TB where RN > (@PageNo-1) * @pageSize and RN
Another method is to use the sort field as a variable, through dynamic SQL implementation, can be changed to a stored procedure.
Copy Code cod
Copy CodeThe code is as follows:
/*
* Class:mssql
* TIME:2009-12-10
* Author:libaochang
* version:1.0b
* Description:mssql Database access Class,it can execute the Procedur or SQL
*/
Class Mssqlutil
{
var $user = null; Database user Name
var $keys = null; Database user Password
var $host = ' localhost '; Database host NAME/IP and port
var $base = null; Database name
var $link = null; Create link
/**
* Construct function init all parmeters
* @param
Create a stored procedure and return the primary key of the table by passing in the table name parameter. The Stored Procedure Code is as follows:
Create proc pgetpkcolumn
(@ Tablename varchar (50 ))
As
/*
Create by leleyl
Obtain the auto-incrementing column of the data t
Copy Code code as follows:
/*
* Class:mssql
* TIME:2009-12-10
* Author:libaochang
* version:1.0b
* Description:mssql Database access Class,it can execute the Procedur or SQL
*/
Class Mssqlutil
{
var $user = null; Database user Name
var $keys = null; Database user Password
var $host = ' localhost '; Database host NAME/IP and port
var $base = null; Database name
var $link = null; Create link
/**
* Construct function init all parmeter
Recently, I am doing a paging query of several million pieces of data. I have studied various solutions and tested it with the actual database of the project on the local machine. The testing process is very, which is so painful that I cannot look back at ing. Now, I don't want to talk much about it. I believe that this is the preferred way for most people who search for answers.
The following is the Stored Procedure Code:
Copy codeThe Code is as fol
Stored Procedures
The stored procedure is as follows:
CREATE PROCEDURE Test@TableName Char (20),@ii char Output,@bb char (Output)AsSET NOCOUNT ON/*if exists (select 1 from demo_table where T_name= @TableName)Set @ii = ' Yes 'ElseBegin--raiserror (' not have such a table ', 16, 1)Set @ii = ' No 'End*/Select @ii = t_id from demo_table where t_name = @TableNameIf @i
1. No external parameters are used in the stored procedure.Stored procedures:SET ansi_nulls ongoset quoted_identifier ongo--=============================================--Author:HF_ ultrastrong--Create date:2015 July 19 22:09:24--Description: Determine if there is data and return value using return-================================ =============create PROCEDURE re
Copy codeThe Code is as follows:-- Usage instructions: This Code applies to MsSql2000 and is available for other databases, but not necessary.-- Create a stored procedureCreate procedure pagination@ TblName varchar (255), -- table name@ StrGetFields varchar (1000) = '*', -- the column to be returned@ FldName varchar (255) = '', -- Name of the sorted field (such as TABLE. FLDNAME format)@ PageSize int = 10,
;= ' ka ' Then ' K 'When substring (@str, @intLen, 1) >= ' not ' then ' J 'When substring (@str, @intLen, 1) >= ' hafnium ' Then ' H 'When substring (@str, @intLen, 1) >= ' there ' then ' G 'When substring (@str, @intLen, 1) >= ' fa ' then ' F 'When substring (@str, @intLen, 1) >= '??? ' Then ' E 'When substring (@str, @intLen, 1) >= '?? ' Then ' D 'When substring (@str, @intLen, 1) >= ' cha ' Then ' C 'When substring (@str, @intLen, 1) >= ' eight ' then ' B 'When substring (@str, @intLen, 1) >=
page.Declare @ PageNo int, @ pageSize int;Set @ PageNo = 2Set @ pageSize = 20Select * from (Select row_number () over (order by getdate () rn, * from sys. objects)Tb where rn> (@ PageNo-1) * @ pageSize and rn
Another way is to use the sorting field as a variable and use dynamic SQL to change it to a stored procedure.Copy codeThe Code is as follows: declare @ PageNo int, @ pageSize int;Declare @ TableName varchar (128), @ OrderColumns varchar (500), @ SQL varchar (max );Set @ PageNo = 2Set @ pa
Create PROCEDURE [dbo]. [ShowPage]@ TblName varchar (255), -- table name@ StrGetFields varchar (1000) = '*', -- the column to be returned@ StrOrder varchar (255) = '', -- Name of the sorted Field@ StartRowIndex int = 0, -- obtains the sequence number of the first row in the result (starting from the number of rows)@ MaximumRows int = 10, -- the number of rows displayed on each page (the number of rows retri
In general small data paging is that we use a simple paging function on it, but if the millions data paging, then I have to consider the efficient MSSQL stored procedure paging code OH.DECLARE @TotalCount intDECLARE @TotalPageCount intexec p_viewpage_a ' type1 ', ' * ', ' id ', ', ' ID ASC ', 1,0,4,3, @TotalCount output, @TotalPageCount output
SELECT * FROM Type1
Crea
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.