开发者

Install SQL database in the drive where SQL Server is installed

开发者 https://www.devze.com 2023-02-24 10:11 出处:网络
CREATE DATABASE [JKamdar_Soft] ONPRIMARY ( NAME = N\'JKamdar_Soft\', FILENAME = N\'C:\\Program Files\\Microsoft SQL Server\\MSSQL.1\\MSSQL\\DATA\\JKamdar_Soft.mdf\' , SIZE = 2048KB , MAXSIZE = UNLIMI
CREATE DATABASE [JKamdar_Soft] ON  PRIMARY 
( NAME = N'JKamdar_Soft', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\JKamdar_Soft.mdf' , SIZE = 2048KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'JKamdar_Soft_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\JKamdar_Soft_log.ldf' , SIZE = 1024KB , MAX开发者_StackOverflow社区SIZE = 2048GB , FILEGROWTH = 10%)
 COLLATE SQL_Latin1_General_CP1_CI_AS
GO

I have these statements in database install file. In above example the OS is installed in C Drive. But we couldn't be sure in which drive the Client's Program Files folder would be. Is there any method in sql which says that "pls install database where OS is installed". Or any alternative method which makes sure the database is installed to correctd drive.

Answer

The above script sets a fix location to the the SQL Database. We just need to remove the unnecessary lines in above script. We just need to write the following:

CREATE DATABASE [JKamdar_Soft]
COLLATE SQL_Latin1_General_CP1_CI_AS
GO

And it automatically installes to the default instance of SQL Server.


The above script sets a fix location to the the SQL Database. We just need to remove the unnecessary lines in above script. We just need to write the following:

CREATE DATABASE [JKamdar_Soft]
COLLATE SQL_Latin1_General_CP1_CI_AS
GO

And it automatically installes to the default instance of SQL Server.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号