Tags: style io os ar strong art SP CTI on1. Write scalar value function iconvert2stringCREATE FUNCTION iconvert2string (@N int,@f INT) RETURNS varchar (ten) Asbegindeclare @M intdeclare @L0 intdeclare @CH VARCHAR (10) DECLARE @ST VARCHAR () Select @CH = "Select @ST =convert (VARCHAR), @N) Select @ST =rtrim (@ST) Select @L0 =len (@ST) Select@m=1while (@mDescription: The parameter @f is the length of the variable part after the string. 2. Write a scalar-valued function that returns a primary key s
Label: 1AlterPROCEDUREP_resource_info_select_by_classification_id_and_keyword2 @classification_id INT,
3 @keyword NVARCHAR( -)
4 as
5 BEGIN
6 SELECT * fromT_resource_infoWHERE
7(',' +Ri_classifications+ ',') like '%,' + LTRIM(RTRIM(STR(@classification_id)))+ ',%'
8 and(CONVERT(VARCHAR(MAX), Ri_author) like '%' + @keyword + '%' ORRi_title_cn like '%' + @keyword + '%')
9 END
Ten GO
One
A EXECP_resource_info_select_by_classification_id_and_keyword the,'a '
Text type:Char: fixed -length non- Unicode character data with a maximum length of 8,000 charactersVARCHAR: variable -length non- Unicode character data with a maximum length of 8,000 charactersText: Store long text messages with a maximum length of 231-1 (2147483647) charactersNCHAR: fixed-length Unicode character data with a maximum length of 4,000 charactersNVARCHAR: variable-length Unicode character data with a maximum length of 4,000 charactersntext: Storing long text messages up to 230-1 (
Tags: code cas log Express pre time div conversion data type1. Cast functionGrammar:CAST (expression as data_type [(length)])| | | | The maximum length of the data type that the keyword expression or value is to be converted to Example:SELECT CAST (as CHAR (3))2. Convert functionGrammar:CONVERT (data_type [(length)], expression [, style])| | | | | the maximum length ex
server| Sample | data
Example of tree data processing in SQL Server 2005--Create test dataif exists (SELECT * from dbo.sysobjects WHERE id = object_id (n ' [TB] ') and OBJECTPROPERTY (ID, n ' isusertable ') = 1)drop table [TB]Go
--Sample dataCREATE TABLE [TB] ([id] int PRIMARY key,[pid] int,name nvarchar (20))INSERT [TB] SELECT 1,0,n ' China 'UNION all SELECT 2,0
The most recent problems with Access databases are summarized:
The use of like in Access
Like wildcard usage in Access is this:
“?” Represents any single character; "*" means 0 or more characters; "#" means any number
So it should be:
SELECT * from DatabaseName where fieldname like ' *xx* '
But in SQL SERVER, 0 or more characters are represented in%
Ii. How to query the date range data fo
Tags: primary key fetch data ALS PKI fine database table display data modelThe bit value is saved to 1/0, and 1 for true,0 represents falseWhen reading database data, the field can be read directly with the bool type and converted directly to True/false database table Structure create table [dbo].[ Bittable] ([PKID] [int] identity ( 1,1) not null, [Isdelete] [bit] NULL, PRIMARY key CLUSTERED ([PKID] ASC) with (pad_index = off, Statistics_norecompute =
================================== Declaration ==================================This article is original, reproduced in the text of the influential annotated author and source, and to ensure the integrity of the article.Do not modify (including this statement) without the consent of the author, and reserve the right of legal investigation.Do not use for publication, printing or academic reference without the consent of the author.In order to ensure the correct contents, we suggest that we shoul
For the first time in more than 4-5 years, Microsoft has tried to rewrite the query execution engine that was established in SQL Server version 7, released in 1998. The goal of rewriting is to provide a high speed similar to NoSQL without sacrificing the characteristics of the relational database.
At the heart of this one attempt is the Hekaton project, the Memory tuning table. Although it can still be acc
Get Data fields (field and type information for a table)SELECT Table name= CaseWhen a.colorder=1Then D.nameElse "'End, table description= CaseWhen a.colorder=1Then IsNull (F.value,"')Else "'End, field ordinal=a.colorder, field name=a.name, Logo= CaseWhen ColumnProperty (A.id,a.name,'isidentity')=1Then'√'Else "'end, primary key= CaseWhen exists (SELECT1From sysobjectswhereXtype='PK'and nameinch(SELECT name from sysindexes WHERE indidinch(SELECT indid f
Label:If you design data of the amount type in the project, have you ever considered why you cannot use the float type?Here's an example:DECLARE @price1 FLOAT; SET @price1 = 1; SET @price1 = (@price1 * 7.1)/7-@price1 * 0.1SELECT @price1;D eclare @price2 DECIMAL; SET @price2 = 1; SET @price2 = (@price2 * 7.1)/7-@price2 * 0.1SELECT @price2;Execute to see how the results are:0.9142857142857141Here is a recor
Sometimes a partition function is built on the job, but a partition function like a date can have a value of hundreds of if it's not going to kill me. So I wrote a bit of code to automatically generate a monthly partition function and a corresponding partition theme starting from 1990. Use [TestDB]GODECLARE @STR NVARCHAR(MAX)SET @STR = 'CREATE PARTITION FUNCTION [pf_rangebymonth_fromyear1990] (DATETIME) as RANGE left for VALUES ('DECLARE @STR2 NVARCHAR(MAX)SET @STR2 = 'CREATE PARTITION SCHEME [p
from -1.79e + 308 to 1.79E + 308. The parameter n indicates whether the field holds 4 bytes or 8 bytes. Float (24) holds 4 bytes, while float (53) holds 8 bytes. The default value for N is 53. Money, a monetary data between -922,337,203,685,477.5808 and 922,337,203,685,477.5807. RelA, floating precision digital data from -3.40e + 38 to 3.40E + 38. Date Type: DateTime, from January 1, 1753 to December 31, 9999, with a precision of 3.33 milliseconds. d
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.