1. TVP, table variable, temporary table, CTE difference
Both TVP and temporary tables are indexed, always in tempdb and increase system database overhead, while table variables and CTE are written to tempdb only when memory overflows. For a large
In section 2005, we have more options. We can use the new syntax CTE (Public table expression). The paging stored procedures include the following:
1. Use Not in and select top
2. Use the value of id greater than or select top
3. Use the cursor in
During work, we often encounter the need to copy data from a remote client database to a local machine for testing. It is not worthwhile to download the entire database. The following script can be used to generate an Insert script based on the
/*-------------------------------------------------------------------------------Function:Generate table record SQL statement (note text and ntext fields are exported to null)Parameter description:@Table_Name Table Name@IsPrint whether to print
Of course there are other tools to do this, but the script will work if the client doesn't allow you to mess with the server.
Copy Code code as follows:
DECLARE @tbImportTables Table (tablename varchar (128), deleted tinyint)
Learning Notes (13)--knowledge points and considerations for database backup and restoreFirst, the basic concept of backup and restore1. Full backup: Full backup because the amount of data that needs to be backed up is large, it needs to be done in
Of course there are other tools to do this, but this script will be useful if the customer does not allow you to install things in the server.Copy codeThe Code is as follows:DECLARE @ tbImportTables table (tablename varchar (128), deleted tinyint)--
How to view the size of a table footprint--Define Table variablesCreate TABLE T([Name] VARCHAR (max),[Rows] IntReserved VARCHAR (max),Data_size VARCHAR (max),Index_size VARCHAR (max),Unused VARCHAR (max))--Store table usage to table variableINSERT
Original: Several common thresholds in SQL Server databaseThe source of this article: http://www.cnblogs.com/wy123/p/6709520.htmlWhat is the maximum length of the 1,sql statement or stored procedure (SQL string capacity)?Often people ask, my SQL
As a little programmer, it is inevitable to deal with where in and like in daily development, in most cases, the parameters we pass are not much simple, single quotation marks, sensitive characters escape, and then directly spelled into the SQL,
As a small programmer, it is inevitable to deal with where in and like in daily development, in most cases, the parameters we pass are not much simple, single quotation marks, sensitive characters escape, and then directly spelled into the SQL,
Recently in the project, you need to convert binary type data into character type data, and found that the original can be written, recorded for the needs of the child boots reference.IF object_id (' Fn_binarytochar ') is not NULLDROP FUNCTION
1. Inserting query data into a staging tableAt first, I wrote this.DECLARE @sql varchar (Max) SET @sql = ' SELECT * to #tmp from TB ' EXEC (@sql) SELECT * from #tmpErrorInvalid object name ' #tmp 'It can be changed into this.CREATE TABLE #tmp (...)
Bit integerThe BIT data type is an integer, and its value can only be 0, 1, or null. This data type is used to store data with only two possible values, such as yes, no, true, or fa lse, on, or off.Int integerInt data type can store integers from-231
Copy codeThe Code is as follows: create function fGetStrBySplit
(
@ Source VARCHAR (max ),
@ Index INT,
@ SplitChar VARCHAR (1)
)
RETURNS varchar (MAX)
AS
BEGIN
DECLARE @ Len INTDECLARE @ n INT = 0DECLARE @ ChIndex INTDECLARE @ Result
3, downlink SMS Send WebServiceDevelop a webservice for third-party system calls to send SMS messages. After the webservice receives the data, it stores the information into the database's SMS Send data table.The webservice parameters include: App
--Show---Create proc Up_show@tableName varchar (8000),--table name, view name@indexCol varchar = ' id ',--Identifies the column name (e.g., primary key, identity, index column recommended)@pageSize int = 10,--page size@pageIndex int = 0,--current
I'm sure you'll often encounter problems exporting SQL Server query results to Excel. If you export fewer times, direct "Save Results as ..." Yes, but when it comes to sampling each table separately, it's pretty messy. Today to provide you with a
But we can solve this problem in a different way. Here's how to analyze the solution.
Data for text or ntext types cannot be string manipulated in a query. The most common use is to treat the text as varchar (when the actual content is less than 800
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.