Jump to content

Any Sql Dbas Here Urgent Help


Recommended Posts

Posted

How can I write a automated script to create a database.
I need a bat file or cmd file to be created if executed that cmd file I have database created

Posted

SQl command ni file lo petti adi batch lo pettu..

 

mysql -uroot -ppassword < createDb.sql;

Posted

your .sql command shud look something like this..

# uninstall if anything's already there
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%';
DROP USER 'username'@'%';
DROP DATABASE IF EXISTS `tablename`;

# create the user
CREATE USER 'username'@'%' IDENTIFIED BY 'password';
CREATE DATABASE IF NOT EXISTS `tablename`;
GRANT ALL PRIVILEGES ON `tablename` . * TO 'username'@'%';
Posted

I have the script bro I just want to integrate in a bat or cmd file so that database gets created with a click just have to provide database name as a parameter

Posted

I have the script bro I just want to integrate in a bat or cmd file so that database gets created with a click just have to provide database name as a parameter

 

a file unte.. kinda code copy paste chesi..save it as .bat file...

mysql -uroot -ppassword < createDb.sql;
Posted

How abt for MS SQL server

 

daniki Powershell is better..

#Import SQL Server Module called SQLPS
Import-Module SQLPS -DisableNameChecking
 
#Your SQL Server Instance Name
$Inst = "YourInstanceName"
$Srvr = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server -ArgumentList $Inst
 
#database PSDB with default settings
#by assuming that this database does not yet exist in current instance
$DBName = "AFDB"
$db = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Database($Srvr, $DBName)
$db.Create()
 
#Confirm, list databases in your current instance
$Srvr.Databases |
Select Name, Status, Owner, CreateDate
Posted

That's working but bro to tweak what should I do
Say if my server has not setup model database as desired and I want these data files and log files to be created on a destination

×
×
  • Create New...