Back up and restore a database

Source: Internet
Author: User
CREATEPROCEDUREprotest (@ var1int, @ var2int, @ var3intoutput) ASset @ var3 @ var1 + @ var2 + @ var3return @ var3GO declare @ var1intset @ var11declare @ var2intset @ var22declare @ var3intset @ var33ex

Create procedure protest (@ var1 int, @ var2 int, @ var3 int output) AS set @ var3 = @ var1 + @ var2 + @ var3 return @ var3 GO declare @ var1 int set @ var1 = '1' declare @ var2 int set @ var2 =' 2 'Clare @ var3 int set @ var3 = '3' ex

Create a stored procedure
Create procedure protest
(
@ Var1 int,
@ Var2 int,
@ Var3 int output
)
AS
Set @ var3 = @ var1 + @ var2 + @ var3
Return @ var3
GO

Use stored procedures
Declare @ var1 int
Set @ var1 = '1'
Declare @ var2 int
Set @ var2 = '2'
Declare @ var3 int
Set @ var3 = '3'
Exec protest @ var1, @ var2, @ var3 output
Select @ var3

Back up database
Backup database pubs
To disk = 'C:/test/pubs. Bak'

Restore database
Restore database test
From disk = 'C:/test/pubs. Bak'
With move 'pubs' to 'C:/test. mdf ',
Move 'pubs _ log' to 'C:/test. ldf'

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.