1. Char, varchar, nvarchar differenceChar fixed length character data length 8000 characters, less than 8000 characters are filled with spaces.varchar variable long character data maximum length 8000, less than 8000 characters are not filled with
Use Testgoifexists (SELECT* from sys.objects WHERE object_id = object_id (N'gettime') and typeinch(N'FN'N'IF'N'TF'N'FS'N'FT'))--determine if the custom function is present in the drop function gettime--Delete the Custom function Gocreate functions
--Enable or disable all foreign KEY constraints for the specified tableALTER TABLE Tbname NOCHECK constraint allALTER TABLE Tbname CHECK constraint all--View constraintsSelect Name, is_disabled from Sys.foreign_keys order by name--DisableALTER TABLE
Select * fromlol--Top KeywordsSelect Top 3 * fromlol--query first three linesSelect Top 3 * fromlolwhereAge> A --Join conditionsSelect Top 3Name,wuqi fromlolwhereAge> A ----keyword DISTINCT query different items go to weightSelect distinctName
The OR logic is used because it conforms to people's thinking habits. It is also quite straightforward to use logical expressions with OR logic to determine the priority and row after the anchor line. However, because of how the SQL Server optimizer
Definition and usageThe DATEPART () function is used to return a separate part of a date/time, such as year, month, day, hour, minute, and so on.GrammarDATEPART (Datepart,date) The date parameter is a valid day expression. The datepart parameter can
Select * fromStudent--Querying the databaseCreate Databases20150417--New DatabaseDrop Database [20150325] --to delete a database number starts with [] surround Uses20150417--Working with DatabasesGo --connector is not written or can beCreate
1, create a new read-only user that can access only one table.--Add users who only allow access to the specified table:Execsp_addlogin ' username ', ' password ', ' Default database name '--Add to DatabaseExecsp_grantdbaccess ' User name
' Create login UserUse masterCreate login [Mashenghao] with password= ' Kline ',DEFAULT_DATABASE=[KCHNETDB], Default_language=[us_english], Check_expiration=off, Check_policy=off' The following can create a user for a different databaseUse Kchnetdb'
1.Top Query StatementsSELECT TOP n from [Query condition]Used to get the number of data bars returned by the rule.SELECT TOP N PERCENT from [Query condition] Indicates the number of data bars for which the previous percentage was obtained.2.LIKE
Use SQL Server to number each group of records sequentiallyProject business needs, the number of each group of records, to facilitate row to column, the person is positioned to a specific row; After SQL Server 2005, the Row_number () function is
1, in the database to create a new login, is your computer user name, such as Computername\youname2. Grant sysadmin permission to this user: Sp_addsrvrolemember ' computername\youname ', ' sysadmin 'This allows you to debug locally.If you want to
1.DISTINCT DISTINCT This keyword is used to filter out redundant duplicate records to keep only one, but it is often used only to return the number of distinct records, rather than using it to return all values that are not re-recorded. The reason
The 1.distinct is used to return a value that is removed from the duplicate and used to remove the select distinct name from student2.select newid () generates a unique value that is not duplicated. Both globally unique identifiersThe difference
Adjust the SQL server running database structure and SQL Server database
The database structure during development must be modified repeatedly. The most troublesome case is that the developer's database structure has been modified, and there is a
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.