Label:Find the table name or the name of the stored procedure in the system table before processing it with a cursor Ps:sqlserver 2000 is using the system table is sysobjects, the Type field is: xtype; The system table for SQL Server 2005 or later is sys.objects, and the Type field is type In this article, for example, Sql2005, Sql2000 version, please follow the above instructions to replace Note the value
Because of the unreasonable preliminary database design, the length of the primary and Foreign keys associated with multiple tables is inconsistent. As a result, when the fields that are too long in the primary and Foreign keys are filled with the same field, the extra part is filled with null characters. The trim () method is used in the where statement associated with multiple tables.
Because of the unre
SQL Server temporary tables are frequently used. The following describes how to use SQL Server temporary tables to prevent repeated user logon.
When developing business software, we often encounter the following problem: how to pr
, Ss.sum_total_logi Cal_writes from (SELECT s.plan_handle, SUM (s.execution_count) Sum_execution_count, SUM (s.total_elapsed_time) sum_total_elapsed_time, sum (s.total_worker_time) Sum_total_worker _time, sum (s.total_logical_reads) sum_total_logical_reads, sum (s.total_logical_w Rites) sum_total_logical_writes from Sys.dm_exec_query_stats s GROUP by S.plan_handle) As SS Cross APPLY sys.dm_exec_sql_text (ss.plan_handle) T ORDER by Sum_total_logical_reads DESC
I. List of databases1. List all librariesUse Master;goselect name,dbid from master.dbo.sysdatabases2. List only user librariesUse Master;goselect name,dbid from master.dbo.sysdatabases where dbid>4;Ii. list tables in a library1.
Tags: problem: Mode needs to manage LTE account the Mode editor RosTo resolve an issue that does not have SQL Server authentication enabled:1. Run regedit and go to Registry Editor2. Open: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL server\mssql14. Mssqlserver\mssqlserver (MSSQL14. MSSQLSERVER This section is s
Tags: arc sql ima LTE div database pre hone alterCreate DATABASE test
go use
test
go
CREATE TABLE UserInfo
(
Id INT IDENTITY PRIMARY KEY,
Name VARCHAR,
Age INT,
Sex BIT,
Address VARCHAR (+)
)
GO
ALTER TABLE dbo. UserInfo ADD Phone VARCHAR (one)
ALTER TABLE dbo. UserInfo ADD CONSTRAINT Age_c CHECK (age>0 and age SQL SERVER build libraries,
In SQL Server 2005/2008, if an ordered record is inserted into a staging table, the records queried from the staging table are ordered (not dependent on order by and ordered), but starting with SQL Server 2012, even if the inserted recordset is orderly, The result of the query becomes unordered. You need to rely on ord
', ' bj06 ') go--Show all student Records SEL ECT * FROM student Go-connect query select * FROM student, class where student. Class number = class. The class number go--The following effect is the same as the same--select the student. Student number, Class. Class number, student name Word, class. Class name from student, class where student. Class number = class. The class number go--The following effects are the same--query the students in class sel
The code is as follows: The code is as follows:Copy code Declare @ t varchar (255), @ c varchar (255)Declare table_cursor cursor for select a. name, B. nameFrom sysobjects a, syscolumns B, policypes cWhere. id = B. id and. xtype = 'u' and c. name/* "u" indicates the data type you want to operate on. You do not need to change it to all data types */In ('char ', 'nchar', 'nvarchar ', 'varchar', '
Tags: sys database name SQL Server int distrib user ATI org table nameexec sp_configure ' show advanced options ', 1 reconfigureexec sp_configure ' Ad Hoc distributed Queries ', 1 reconfigureSELECT * into t_system_organization_bak_20180308From OPENROWSET (' SQLOLEDB ', ' 10.***.***.***, port; ' User name '; ' Password ', [Database name].dbo. Table name]exec sp_configure ' Ad Hoc distributed Queries ', 0 rec
The computer re-installed sqlserver2008 R2 (English), New data table, new field, found that there is a field type set wrong, want to modify the field type, and the table has been saved, that is, after saving to modify the field properties. However, the modified settings cannot be saved, prompting "saving changes is not permitted" (specifically)Workaround:Find the Tools->options in the menu bar, find the designers, and then prevent saving changes that require table re_creation front of the tick,
only logically ordered by the table data chain.2. Nonclustered indexesNonclustered indexes have a similar B-tree index structure to clustered indexes. The difference is that nonclustered indexes do not affect the order of data rows. What do you mean, the non-clustered index, the leaf level does not contain all the data, only the key values and the index row in each leaf node contains a bookmark (bookmark), the bookmark in the clustered index is the c
distribution server]
-> Use the following servers (the selected servers must be configured as distribution servers)-> [Selected servers] (for example, Fengyu/Fengyu)
-> [Next]-> [enter the password of the distributor_admin user of the distributor (for example, Fengyu/Fengyu) Twice]
-> [Next]-> [custom configuration]-> [No, use the following default configuration]
-> [Next]-> [complete]-> [OK]
Create a database copy and release process:
[Copy]->
sentence is the database name + owner + Table Name
-- Directly export the "out" parameter
-------------------------------------------/* If you want to use a query to export some fields to excel */
Exec master .. xp_mongoshell 'bcp "select orderid, cutomerid, freight from northwind .. orders order by orderid "queryout c: \ book2.xls-C-s" (local) "-U" sa "-P ""'
-- A query statement is added to BCP and enclosed in double quotation
The last time we introduced simple data export and import, we only operate on a single file. If we want to import data to all the files under a directory at the same time, how can we achieve this? SSIS provides the foreach loop container in the control flow, which is easy to understand. Compared with the sequential container, SSIS can traverse and execute cyclically, you can repeatedly execute the control flow for each member of the specified enumerat
I. Querying the database (Sys.databases--select *from sys.databases where name= ' Select *fromwhere name='MyDatabase'Second, query table (sysobjects--select *from sysobjects where id=object_id (' Select *fromwhere id=object_id ('studentsinfo')Third, query column (Syscolumns--select COUNT (*) from syscolumns where name= ' Select from where name='sname' and id=object_id ('studentsinfo ')Iv. querying a stored procedure or view (SELECT * from sysobjects where name= '
. nvarchar () double-byte storage. Text: Large space. C. Date data type: Datetime,smalldatetime D. Photo type: Image, generally not used, only the database record location.4. FOREIGN KEY constraintsRight-to-load, from table (foreign key table) to main table (primary key table).The data in the primary table cannot be deleted until the data in the child table is deleted.5. Check constraintsColumn value right--->check constraint--add keyword (email like '%@% ')6. Build diagramGraph right---Select
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.