However, user A exists in database A, while user A cannot grant permissions to user A in the new MSSQL statement. Create A new user B. The table and other information created by user A cannot be accessed. The solution is found here:
Run the
The two methods work in the same way.
Method 1:
Copy codeThe Code is as follows: procedure SQLCloseAllTrack;
Const
SQL = 'Clare @ TID integer '+
'Descare Trac Cursor For '+
'Select Distinct Traceid FROM: fn_trace_getinfo (default) '+
'Open trac'
From SQL server help documentIt helps you optimize the query speed!
RecommendedSp_executesqlInstead of using the EXECUTE statement to EXECUTE a string. Support Parameter replacement not onlySp_executesqlMore common than EXECUTE, and also
Use the following statement to update a batch of records:
Update publish set contentid =
(Select top 1 articles. contentid from articles
Where articles. articleID = publish. objectID
)
-- Where publish. objectid = @ objectID
The premise is that the
1. ranking function and PARTITION
Copy codeThe Code is as follows: -- all data
SELECT * FROM dbo. student AS a inner join dbo. ScoreTB AS B ON a. Id = B. stuid
WHERE scorename = 'China'
-------------------------------------------
-- The usage of ROW_
The data block cursor example is as follows:
Begindeclare @ item_code varchar (32) -- defines the variable declare @ item_name varchar (32) Declare @ invest_money_sum float -- defines the cursor declare my_cursor cursor forselect item_code,
Custom Function + cursor, function cursorZookeeper
Use yuyongTestGo
Create function dbo. getTotByName (@ _ name nvarchar (50 ))Returns intAsBeginDeclare @ tot int;Set @ tot = 0;Declare @ name nvarchar (50 );Set @ name = '';Declare stuName
The database cannot be restored. solution:
During the Restore database operation, you may be prompted that you cannot obtain the exclusive access to the database because the database is in use !!
In this case, you must first kill the threads that
1. Select all contents in the table and return a dataset.
Create procedure mysp_allAsSelect * From ajaxcityGo
2. query based on input parameters and return a dataset
Create procedure mysp_para@ Cityname varchar (255 ),
@ Short varchar
Job operations
Enterprise Manager-- Manage-- SQL Server proxy-- Right-click a job-- Create a job-- Enter the job name in "general"-- "Step"-- New-- Enter the step name in "Step name"-- Select "Transact-SQL script (tsql)" in "type" -- for example,
This is the stored procedure for terminating the process.Use masterGo----------------------------------------- Disable all access processes to the specified database---------------------------------------------Create proc killspid@ Dbname varchar (20
Declare employee_cursor cursor
Select updatetime, ID
From tblsimaccounthistory
Order by updatetime, ID
Open employee_cursor
Declare @ updatetime datetime
Declare @ ID decimal
Declare @ hid decimal
Select @ hid = 1
Fetch next from
Kill the database process, which is often used in the case of separate operations and also for deadlocks.
Code Segment 3: Force disconnect a user from a process (also commonly used in deadlocks ).-- Kill the connection process of the
Databases often encounter the need to replace some content in batches. Sometimes it is because there is no encoding when storing data, and sometimes it is because of poor information that must be replaced directly. I sorted out how to replace with
From http://hi.baidu.com/yocnnzrmilceijr/item/d1d928f8e8cc73ea1b111f07
Delete all tables:
If table deletion fails due to foreign key constraints, delete all constraints first:
--/Step 2 *********** Delete the foreign key constraints of all
A cursor provides a flexible means to operate the data retrieved from a table. In essence, A cursor is actually a mechanism that can extract a record from a result set that contains multiple data records. A cursor is always associated with a t_ SQL
Construct a dynamic SQL statement to obtain the return value from the cursor.
Declare @ tablename varchar (200)
Set @ tablename = 'tmpbasecustomer _ 9'
declare @ SQL nvarchar (4000) set @ SQL = n' declare @ repeatstr varchar (1000)
The reason for this problem is that a user connects to the database to be restored, and the users here even include the users to be restored. The solution is to close all connections to the database to be restored.
① Switch the database to the
CopyCodeThe Code is as follows: declare @ t varchar (255), @ C varchar (255)
Declare table_cursor cursor for select a. Name, B. Name
From sysobjects A, syscolumns B, policypes C
Where a. ID = B. ID and A. xtype = 'U' and C. Name
In ('Char ',
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.