SQL Server focuses on optimization of Stored Procedure performance, data compression, and page compression to improve IO performance (I ).
Preface
The SQL Server basic series is not over yet, And the last point is not written, and will continue later. Some school friends asked me when I began to write the
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
Tags: put ant negative public lines syn SEM var withWe have a Sea macro commercial ERP3, the inventory is written with stored procedures, reduce inventory will first check the negative inventory, such as there are 5 you think of the library 6, the stored procedure is RAISERROR (' Insufficient inventory ', 16, 1). After the recent release of this version, some cus
When the server| stored procedure first used SQL Server 2005, it did not know how to save it after modifying the stored procedure.
I found the appropriate stored procedure in the
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
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
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
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"
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
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);
determine if the database exists
If db_id (N ' DATABASENAME ') is not null
the methods for judging tables, views, stored procedures, and cursors are summarized as follows:
use databasename--jump to the specified database
go
if object_id (n ' a ', n ' U ') is not null
drop Table a
go
Note: A is a table and U represents a data table type
Type code similar to U, as
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
DECLARE @newsID INT
OPEN My_cursor
FETCH NEXT from My_cursor into @newsID
IF (@newsID is not NULL)
DELETE from Tb_news_type WHERE typeid= @typeID
Execute Proc_tb_news_delete @newsID = @newsID--Execute stored procedure
while (@ @FETCH_STATUS BEGIN
SET @newsID =null
FETCH NEXT from My_cursor into @newsID
IF (@newsID is not NULL)
DELETE from Tb_news_type WHERE typeid= @typeID
Execute Proc_tb_news_
If you need to regularly execute a stored procedure or SQL statements of less than 3200 characters in SQL Server, you can use management> SQL Server proxy> job.
1. Choose "manage"> "SQL Server proxy"> "job" (right-click)> "creat
Use [capitalfortune]Go/***** Object: storedprocedure [DBO]. [setmultipages] script Date: 05/30/2012 10:17:02 ******/Set ansi_nulls onGoSet quoted_identifier onGo-- ===================================================== ======-- Author: hugejile-- Alter Date: 2070-9-29-- Description: pagination. Do not change it at will.-- ===================================================== ======Alter procedure [DBO]. [setmultipages]-- Add the parameters for the
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.