Summary of SQL server script update for databases. For more information, see.
Summary of SQL server script update for databases. For more information, see.
Table replication:
1. insert
Tags: tin pre ATI Subscription. NET stat Func PSU startOriginal: SQL Server transactional replication uses scripts to add publications for an object--use [Publish library]--Add Table: Create the project and add it to the publication exec sp_addarticle @publication = n ' replicationname ', @article = N ' MyObject ', @sourc E_owner = n ' dbo ', @source_object = N '
, Ignore_dup_key = off, Allow_row_locks = on, allow_page_locks = ON) O N [PRIMARY]) on [PRIMARY]GOThen: Insert into Table1 (filed1,filed2) Select Filed1,filed2 from Table2 (this is definitely not a correct notation, self-increment ID problem)thus: SET IDENTITY_INSERT [Table_1] on INSERT to Table1 (id,filed1,filed2) Select Id,filed1,filed2 from Table1 SET IDENTITY _insert [Table_1] Off (SET identity_insert [table_1] on | | OFF allows an explicit value to be inserted into the identity column of th
sqlcmd utility, which can be used at a command prompt, in the Query Editor in SQLCMD mode, in a Windows script file, or in the operating system of a SQL Server agent job (Cmd.exe), enter Transact-SQL statements, system procedures, and script files in the job step. This util
I develop C # winform myself.
Recently came into contact with a task. Generate a script to create the table based on an existing table in SQL.
First, we want to solve the problem from the perspective of stored procedures.
I read some documents on the Internet and found that MSSQL itself does not have this function. I need to write it myself.
Other database objects (Views, stored procedures, and trig
primary key are not allowed to be publishedIf you need to filter the published data, click Add to write the filter criteria, there is no need to filterSet the Snapshot Agent, log read Agent account, click on the security Settings ...Set the followingSet the publication name3. Create a local subscriptionRight click on local subscriptions, click New SubscriptionsChoose a publishing sourceAll agents run on the server in the distribution librarySelect a
1: When a new table does not exist (that is, copy the data while creating a new table with the same structure as the old table) SELECT * to dbo.tablebackup from Dbo.tablenamewhere ID between 0 and 20 2: The new table already exists, inserting data from the old table. (Note: The primary key does not replicate) INSERT into Dbo.tablebackup (Col1,col2,col3,col4 ...) SELECT Col1,col2,col3,col4 ... From Dbo.tablenamewhere ID between 0 and 20 SQL
onA.uid=B.uid--left connection (based on left table, connection right with connection data, not NULL)
Select * fromQ_user a Left JoinUserInformation b--inner can be omitted
onA.uid=B.uid--Right connection (based on the right table)
Select * fromQ_user a Right JoinUserInformation b--inner can be omitted
onA.uid=B.uid--self-connect (just connect yourself to a table and take a different alias)
Select * fromQ_user a Right JoinQ_user b--inner can be omitted
onA.uid=B.uid----------------Union-
Copy the contents of a to a new tableDescriptionWith data table A, you want to export his content to another table B, at which point B is not created and you want to create table B at the same time as the export.SELECT *into B [in Externaldatabase] from ASecond, copy the contents of a to the existing table BDescriptionWith data table A, you want to export his content to another table B, at which point B is created and you want to create table B at the same time as the export.Insert into B (b_col
executed under the current connection, if no error returns 0.@ @FETCH_STATUS: Used in conjunction with the FETCH statement.@ @IDENTITY: Returns the automatically generated identity value of the last sentence running the statement as the result of the last insert or SELECT INTO statement.@ @ROWCOUNT: Returns the number of rows affected by the last statement.@ @SERVERNAME: Returns the name of the local service on which the script is running.@ @TRANCOUN
Label:This article is mainly script examples, more instructions to see Official documents: Auditing (Database Engine) --The audit use master must be created in the master database; GO--Create server Audit Object--https://msdn.microsoft.com/zh-cn/library/cc280448 (v=sql.100). aspx create server AUDIT [Audit_tofile ] To
(Share with others) exploitation. NET to generate a database table creation script, similar to SQL Server to write the CREATE statement of the table in our RDIFramework. NET code generator, there is an application that automatically generates the CREATE statement of the table through the database table, as shown in: many methods have been explored before this fun
* * Data operation between different server databases.
--Create a linked server
exec sp_addlinkedserver ' itsv ', ', ' SQLOLEDB ', ' Remote server name or IP address '
exec sp_addlinkedsrvlogin ' itsv ', ' false ', NULL, ' username ', ' password '
--query Example
SELECT * from ITSV. Database name. dbo. Table name
--Import sample
SELECT * into table from ITSV. Dat
Ps:sql server database Export to SQL script benefits: Small footprint (typically only hundreds of KB), easy to modify, unlimited SQL Server version!1. Right-click the database, select: Tasks-Generate script,2. Click for
Provides a batch processing script code that facilitates the website administrator to use SQLServer to start and stop the service. If you need it, please refer to it.
Provides a batch processing script code that facilitates the website administrator to use SQL Server to start/stop services. If you need it, refer to it.
What we're talking about today is the actual steps of copying SQL Server data into an Access database, copying some of the data in the SQL Server database into an Access database that has the same main structure, not mentioning OpenRowset, Because the Access file and SQL
The following script executes full backup of a database in SQL Server and transfers the backup file to another Server. Backup File naming rules: Database name_timestamp. BAK.
Execution Environment windows 2003 server SQL
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.