1: The following is a relatively simple query method, through the query before the time and query after the difference between the calculation of
Copy Code code as follows:
DECLARE @begin_date datetime
DECLARE @end_date datetime
You cannot create an identical user and mapping the user to the database, and you cannot delete the database user: DemoUser.
Please run the following script and then you can delete the user: DemoUser. Then create the user (DemoUser.) and mapping to
Copy Code code as follows:
CREATE PROCEDURE [dbo]. [Up_pager]
@table varchar (2000),--table name
@col varchar (50),--Paging by this column
@orderby bit,--sort, 0-order, 1-Descending
@collist varchar,--The list of fields to query, *
1. Expand the server object--> linked server--> right click "New Linked Server"
Note: You must be logged on as a database administrator (usually the SA account) before you can create a linked server
2. Enter the IP of the linked server
3. Set
If we insert a value in the identity column, for example:
Copy Code code as follows:
Insert member (ID,USERNAME) VALUES (' admin ')
The error message is returned in the Query Analyzer:[Plain]Reference contentServer: Message 544,
Table types can be used in stored procedures for bulk additionsTable type definition:
Copy Code code as follows:
The CREATE TYPE dbo. Subcardtable as Table
(
[SC_ID] [varchar] (50),
[ZHUKAINFO_ID] [varchar]
batch execution of SQL files with Osql/ocmd batch
Note: In the above illustration we can see that osql does not support all the features of SQL Server 2008, and if you need to use all of the features of SQL Server 2008, you can use the Ocmd
SQL SERVER formula for calculating distances based on map latitude and longitude
Copy Code code as follows:
Go
--Create latitude and longitude distance calculation function
createfunction [dbo]. [Fngetdistance]
--latbegin begins
There are two extended stored procedures in SQL Server that implement the scanf and printf features, and use them appropriately to simplify the SQL code significantly when extracting and stitching strings.
1, xp_sscanf, use it to decompose a
There are three keywords in SQL Server that can modify comparison operators: All, any, and some, where some and any are equivalent.
the official Reference documentHttp://technet.microsoft.com/zh-cn/library/ms187074%28SQL.90%29.aspx
They work
Set SQL Server to use Row_number when not sorted
--1. See NHibernate is so written pagination, it is easier to understand the writing (there should be no efficiency problems?) )
--with just set an alias?
[SQL]
With query as (select Row_number ()
Fixed server role Description
The sysadmin carries out any activity in SQL Server. The role's permissions span all other fixed server roles.
ServerAdmin Configure server-wide settings.
Setupadmin add and remove linked servers and perform certain
When writing SQL statements, many times you use filter to filter out some records, SQL to filter the criteria for short: SARG (search Argument/sarg)
Copy Code code as follows:
where amount>4000 and amount
Of course, this isn't about SQL
Error message: Error mssqlserversqlserveragent could not be started (Reason:sqlserveragent must be able to connect to SQL Server as SysAdmin, but "(unknown)" is not Sy Members of the Sadmin role).
Operating Environment: WINDOWS2003R2 32bit + mssql2
Many friends ask the SQL Server database "Generate script" to export only the SQL scripts for the database, while the table and table data still do not come out. Very simple, look at the tutorial:
Note: I use the SQLServer2008 here, the other
Method 1:
Copy Code code as follows:
TRUNCATE TABLE TableName
When you delete all the data in a table, it automatically grows zero.
If there is a foreign key reference to this table, this method will be an error (even if the primary
Copy Code code as follows:
CREATE function GetColor
(@ well number varchar (50), @ Layer varchar (50))
Returns varchar (200)
As
Begin
declare @sql varchar; set @sql = '
--distinct
Select @sql = @sql + color + ', ' from (
The first is the most traditional way of writing, using variables in the stored procedure as a paging multiplier
Copy Code code as follows:
[C-sharp] View plaincopyprint?create proc P_paged1
@pageSize int, @currentPage int
As
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.