Stored Procedure | data | database
In this example, we take the first two rows from the two tables and merge them into a table.
In reality we often encounter situations where two tables exist in one database, assuming table 1 stores the quarterly sales information for the company's products, and table 2 stores the amount of money owed by the company this quarter. In a page we want to show these two messages. The usual approach is to do two SQL querie
Copy Code code as follows:
--use instructions This code applies to MsSql2000 and is available for other databases. But it's not necessary.
--Create a stored procedure
CREATE PROCEDURE Pagination
@tblName varchar (255),--table name
@strGetFields varchar (1000) = ' * ',--columns to be returned
@fldName varchar
The code is as follows
Copy Code
Create PROC P_viewpage/**//*Nzperfect [No_miss] Efficient common paging stored procedure (bidirectional retrieval) 2007.5.7 qq:34813284Warning: Tables or views that apply to a single primary key or existence of a unique value columnPs:sql statement is 8000 bytes, please note that the incoming parameter and the total SQL length do not exceed the specified ran
Coreseekpython data source reads mssql database build index coreseek builds an index on the python data source, where python reads the content of the mssql database, but the database has too many records (more than 5 million records), resulting in exceeding the available memory limit, an out of memory error is reported. How can I create an index? (Setting the mem
Recently, in the project database optimization process, the database table partition solution was taken into account. mssql2005 added the table partition concept. Now I use the test table to make a table partition. Table partitions can store different data in different database files and separate data by physical addresses. Theoretically, if the server is a multi-disk, multi-CPU, and a disk array, query operations are more efficient.
Currently, table partitions exist in almost all databases, but
MSSQL Create temporary table code
if object_id (' tempdb.dbo. #table ') is not null
drop table #table
Go
CREATE Table #table ([field] type)
The above code is to determine whether the temporary table #table exists, if it is deleted, otherwise create this temporary table.
/*About
Create an index
Suppose you want to find a sentence in the book. You can search one page by one, but it takes a lot of time. By using indexes, you can quickly find the topic you want to search.
The index of a table is very similar to the index attached to a book. It can greatly improve the query speed. For a large table, adding an index usually takes several hours to complete a query. Therefore, there is no reason to add indexes to tables that r
Tips for creating a dynamic MSSQL database table (1): You don't need any other functions to support it. you only need to use some SQL statements provided by MYSQL. For the sake of simplicity, take the MYSQL system table USER as an example to retrieve all possible values in the SELECT_PRIV column. Method: show columns from table_name LIKE enum_column_name the lower-case section needs to be changed according to your situation.
In fact, there is no need
I believe that when you use the transaction rollback method to operate multiple table records in the MSSQL database, the error message "cannot create a new connection in the manual or distributed transaction mode" appears frequently, this problem has plagued me for many years.This time, when developing a large business platform, it involves data computing and must also be updated (or deleted) Multiple table
example, to reference a stored program P or function f associated with the test database, you can call test. P () or test. F ().
· When the database is removed, all stored subroutines associated with it are also removed.
-- When defining a subroutine, You need to insert a space between the name and the brackets that follow. Otherwise, a syntax error occurs. When you call a subroutine, insert it.Create procedure sp_name ([proc_parameter [,...]) [cha
-- Create a job executed on the last workday of each month and call the above stored procedure to automatically create a database
Use masterGo
-- Set the SQL Agent service to automatically startExec MSDB .. sp_set_sqlagent_properties @ auto_start = 1Go
-- Create a jobExec MSDB .. sp_add_job @ job_name = n' automatic da
Turn from:http://www.maomao365.com/?p=4906I. Instead OF triggers apply a method to create a read-only viewBecause instead of is a trigger that performs an INSERT update DELETE statement in place of a table or view,When we create the corresponding trigger, when we perform an INSERT update delete operation on an object, we will jump directly into the instead of trigger to execute.Cases:
nvarchar, @regex as nvarchar) returns nvarchar ( +) as External name iftrue_regex.regexsql.regex_match;gocreate function regex_ismatch (@input as nvarchar (+), @regex as nvarchar (+)) returns Bitas external name Iftrue_regex.regexsql.regex_ismatch;go5: Using functions to implement regular matching SELECT dbo. Regex_ismatch (' abcde123asdf234 ', ' [b-s]+ ') select dbo. Regex_match (' abcde123asdf234 ', ' [b-s]+ ')Note: The above implementation is based on framework3.5, in the framework4.
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.