Label: SQL Server paged query stored procedure used in the project. "Stored Procedures" Create PROCEDURE Prcpageresult--Get the data of a page--@currPage int = 1,--The current page number (that is, top currpage)@showColumn varchar (2000) = ' * ',--required field (i.e. Column
SQL Paging stored Procedure implementation code
Create PROCEDURE Sp_conn_sort(@tblName varchar (255),--table name
@strGetFields varchar (1000) = ' * ',--columns to be returned
@fldName varchar (255) = ',--sorted field name
@PageSize int = 40,--page size
@PageIndex int = 1,--page number
@doCount bit = 0--Returns t
setfilename and addline in a stored procedure.
The stored procedure is as follows (which must be stored in the master database): Create procedure sp_testdll
Exec sp_addextendedproc 'setfilename', 'storeproc. dll '-- declare a fun
1/What are stored procedures and conceptsA stored procedure in Transact-SQL, very similar to. NET language, which can be called repeatedly. After the stored procedure executes once, the statement can be cached so that the statemen
Refresh_vendor_prefix] Warning Code: ' + cast (@ @error as nvarchar) + ' Warning Lines: ' + cast (error_line () as nvarchar) + ' Warning Msg: ' +error_message () ') END CATCH3: Then the C # program runs slowly, but oddly enough, if you run this stored procedure separately in SQL Server Management Studio, it's fast,4: Can not find the cause of the problem, and th
A recent problem was a fast-executing stored procedure that timed out when it was called in the code.Later, I saw two articles:One of the articles is aboutToday, when a colleague calls a stored procedure with code that times out, running in SQL Server Management Studio will
When you first used SQL Server 2005, you didn't know how to save after you modified the stored procedure.
I found the appropriate stored procedure in the SQL Server Management Studio progammability, right click and select "Modify"
Table Structure:Copy codeThe Code is as follows:Create table [dbo]. [Xtest] ([ID] [bigint] IDENTITY (1, 1) not null,[XName] [nvarchar] (50) NULL,[XDemo] [nvarchar] (500) NULL,CONSTRAINT [PK_xtest] PRIMARY KEY CLUSTERED([ID] ASC) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY] Insert 0.5 million data records:Copy codeThe Code is as follows:Declare @ I intSet @ I = 1While (@ I BeginInsert into dbo. x
Support Complex CTE statement calls:
Original SQL statement called:
With T (Select ma_id from sa_affair_info where ad_id = 2203 and ai_affair_status = 2 and ai_is_pass = 'true'),Q(Select M. * From sa_main_affair M Join t on T. ma_id = M. ma_index_no), P (Select ai. * From sa_affair_info AI join Q on AI. ma_id = Q. ma_id where ai_affair_status = 2)Select * from P
Use Stored
creation, each subsequent execution of the stored procedure does not need to be compiled, and the general SQL statements are compiled once per execution (so some of the complex logic of SQL recommendations written in the stored procedures);
Instance 1: A stored procedure that returns only a single recordset.
The contents of the Bank deposit form (Bankmoney) are as follows
Id
userid
Sex
money
001
Zhangsan
male
002
Wangwu
Male
,
003
Zhangsan
Male
$
Requirement 1: A
persondao;public void Add (Person p) throws Exception {Persondao.add (P);}}Personservicedaoimpl.java@Repository (value= "Persondao") public class Persondaoimpl extends Sqlsessiondaosupport implements Persondao{public void Add (Person p) throws Exception {getsqlsession (). SelectOne ("Person.add", p); System.out.println ("------------" +p.getallcount ()); The Allcount variable here is defined in the person entity class, or the output data returned by the st
Visual C # tutorial on Dynamically Operating SQL Server database instances (4 ):How to execute a stored procedure with Parameters
The previous article introduced the SQL statement execution method with parameters and the stored procedure
Here we can see a Data Control paging function written in SQL stored procedures, regardless of the Data Control in the development tool, you only need to call this stored procedure to implement this method. It's easy. We no longer need to write a lot of SQL statements on eve
students have not graduated from the list, after graduation can not be selected classes;2 in the batch selection of students, but also need to add a corresponding course;3 Point added after the end of elective course.
The small amount of data may not see the use of Java programs directly to do database operations this way to achieve the weaknesses, because it every time in the operation of the database, there are frequent and database I/O direct interaction, this performance of the sacrifice i
Advantages of Stored Procedure
Why use stored procedures? The following are the main advantages of Stored Procedure technology:
Pre-compiled execution program. SQL Server only needs to compile each
Advantages of Stored Procedure
Why use stored procedures? The following are the main advantages of Stored Procedure technology:
Pre-compilation and executionProgram. SQL Server only needs to compile each
Many friends may have been using SQL Server for development for some time, but have not or rarely used the stored procedures in the project, perhaps some friends think that there is no need to use stored procedures and so on. In fact, when you finish the maintenance phase of a project, you will find that the stored pro
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.