In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Today, I will talk to you about how to copy database stored procedures in sqlserver. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.
In the current work, we need to solve the problem of copying the whole SqlServer database, including the database outline, the stored procedures in the database, the function, the table structure, the main foreign key relationship and all the data in the table, etc., that is to say, the copy version is exactly the same as the original database. After a period of exploration, a relatively simple solution is found: (1) before copying the database, back up the database to a file. (2) create a new database based on the backup file and Restore it. The following Sql statements can be used to backup the database: string.Format ("backupdatabase {0} todisk=' {1}';", dbName,bakFilePath) is created based on the backup file and the Restore new database can be implemented using the following stored procedure: the duplicate code is as follows:
CREATEPROCEDURECopyDB (@ newDbNamevarchar (50),-- new database name @ dbDataDirPathvarchar (100),-- Data folder directory path for database installation @ soureDbNamevarchar (100),-- source database name @ soureBackupFilePATHvarchar (100)-- path for source database backup files) AS declare@sqlvarchar (3000) set@sql=' createdatabase'+@newDbName+' ON (name='+@soureDbName+'_Data, filename='''+@dbDataDirPath+@newDbName+'_Data.mdf'', SIZE=10) FILEGROWTH=15%) LOGON (name='''+@soureDbName+'_Log'', filename='''+@dbDataDirPath+@newDbName+'_Log.LDF'', SIZE=5MB, MAXSIZE=25MB, FILEGROWTH=5MB)-start restoring RESTOREDATABASE'+@newDbName+'fromdisk='''+@soureBackupFilePATH+'''WITHREPLACE 'exec (@ sql) GO
After reading the above, do you have any further understanding of how to replicate database stored procedures in sqlserver? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.