A few days ago, when I upgraded the database of a communtiy server from SQL 2000 to SQL 2005, I encountered a strange problem and reported the following error:
Violation of primary key constraint 'pk _ cs_threads'. Cannot insert duplicate key in
/* -- Paging program implemented by stored procedures
Displays page X of the specified table, view, and query result.
In the case of primary keys or ID columns in the table, query the data directly from the original table. In other cases, use the
1. Execution Process of EXISTS Select * from t1 where exists (select null from t2 where y = x)It can be understood:Copy codeThe Code is as follows:For x in (select * from t1)LoopIf (exists (select null from t2 where y = x. x)ThenOUTPUT THE RECORDEnd
No. Use case when instead.For example, the following statement shows the Chinese year and monthCopy codeThe Code is as follows:Select getdate () as date, case month (getdate ())When 11 then '11'When 12 then '12'Else substring ('february 5, 1234, 80
For example, ISQL is very convenient when you perform advanced configurations, such as running database operations on a client or remotely. For example, what can I do if I intrude into a host with SQL services? ISQL is the best tool.Not only does
Select * from OPENDATASOURCE ('Sqlodb ','Data Source = remote ip address; User ID = sa; Password = password'). Database Name. dbo. Table NameInsert local database name .. table name select * from OPENDATASOURCE ('Sqlodb ','Data Source = remote ip
Copy codeThe Code is as follows:-- Usage instructions: This Code applies to MsSql2000 and is available for other databases, but not necessary.-- Create a stored procedureCreate procedure pagination@ TblName varchar (255), -- table name@ StrGetFields
I. ProblemsTwo tables with 40 or 50 columns are given to find their same columns and different columns.
2. query the columns in two tables. A temporary table exists.
-- # A, # B is a temporary table, which is automatically deleted after the current
Basic Syntax of SQL statementsYin Hong wrote this article, but I can't help but stick it here for viewing information.Because the original text is written in the word, the paragraph is a bit messy.1. The complete syntax of the Select statement is:
Note: copy a table (only copy structure, source table name: a new table name: B)Select * into B from a where 1 <> 1Description: copy a table (copy data, source table name: a target table name: B)Insert into B (a, B, c) select d, e, f from
In SQL Server, you can use the internal Stored Procedure xp_fileexist to determine whether a file exists. If yes, you can use xp_exist shell to delete the file. In addition to determining whether a file exists, xp_fileexist can also determine
The count Statement supports *, column name, constant, and variable, and can be modified with the distinct keyword, and count (column name) does not accumulate null records. Here are some examples to demonstrate the count rule: for example, to make
I downloaded msde2000a today. I tried to find the setup.exe installation program based on the normal installation environment. The error message is displayed in the dialog box: "To ensure security, you must use a strong SA password. Use the SAPWD
After the system is reinstalled or the database is reinstalled, the user name is found in the database after the database is attached, but there is no login name in sqlserver.
For example
First, the user name has the User Name of the
The following is an SQL Server instance. The following SQL statements run in the 2008 environment:DECLARE @ g geography;SET @ g = geography: Parse ('linestring (-122.360 47.656,-122.343 47.656 )');SELECT @ g;SELECT @ g. ToString ();Result
There is a clever SQL technique on ITPUB. Learn it and record it here.The initial problem was as follows:I have a table structure,Fphm, kshmInt32 00000001Int32 00000002Int32 00000003Int32 00000004Int32 00000005Int32 00000007Int32 00000008Int32 000000
/*************************************** ***** **************************************** * ******************** Parameter description: 1. tables: Table Name, view 2. primaryKey: Primary keyword 3. sort: Sorting statement without Order By such as
Sometimes, a database has multiple accounts, including database administrators, developers, and O & M support personnel. Many accounts may have relatively high permissions, for example, DDL operation permissions (creation, modification, deletion of
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.