Database Summary (iii)

Source: Internet
Author: User

1. Create a unique identity:

CREATE TABLE zz (id uniqueidentifier,name nvarchar (10));

INSERT into ZZ (name) VALUES (' zmt ');

Select NEWID () from ZZ;

2. Difference:

NVARCHAR: variable string, length based on no space, Unicode encoding, length 4000, full kanji, definition of how long to insert

VARCHAR: variable string, length based on not fill space, length 8000, half kanji, define how long to insert half

Char: Immutable string, length based on fill space, half kanji, definition how long to insert half

NCHAR: immutable string, length based on white space, Unicode encoding, full kanji, definition of how long to insert

3, Batch update:

Update a set a.username= b.username from user2014 a left joins user2015 b on a.userid = b.ID;

4. Function:

--substring (intercept who, from WHO, intercept a few)

Alter function ZMT (

@username nvarchar (100),

@subfrom int,

@length int)

Returns nvarchar (1000)

Begin

declare @ziduan1 nvarchar (100)--Fields starting from 1 to Subfrom

declare @ziduan2 nvarchar (100)--a field starting from Subfrom to length

Select @ziduan1 =right (@username, Len (@username) [email protected]+1]

Select @ziduan2 =left (@ziduan1, @length)

Return @ziduan2

End

Select DBO.ZMT (' mengting ', 3,2) ' field '

  

Database Summary (iii)

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.