Solved

Command Line Args for SQL Express

Posted on 2007-03-19
16
526 Views
Last Modified: 2011-10-03
I need to create a command line argument for my distributed setup that will tell SQL Express, to make the db single user mode only, as quite install ( /qb parameter), add the user name and password.
I have looked at Microsoft's site, but no real structure there.  What I need is a sample of what the command line would look like.  
0
Comment
Question by:Sheritlw
  • 8
  • 5
  • 3
16 Comments
 
LVL 4

Expert Comment

by:meenasree
ID: 18754135
the below link has good info as to commandline args
http://msdn2.microsoft.com/en-us/library/ms165702.aspx
0
 

Author Comment

by:Sheritlw
ID: 18754150
That is the same link I looked at.  I need something like

"Setup.exe server:.\SQLEXPRESS /database:Name /username:UserName /password:Password /qb"

but for sqlexpress command line
0
 
LVL 4

Expert Comment

by:meenasree
ID: 18754154
you cannot tell the setup.exe instead you can create a customaction that will have a script or batch file that calls the cmdline utility to tell sqlexpress to do what you want
0
 

Author Comment

by:Sheritlw
ID: 18754166
I can send command lines from my setup program, I just need to format to send
0
 
LVL 4

Expert Comment

by:meenasree
ID: 18754249
0
 

Author Comment

by:Sheritlw
ID: 18754261
I read that one to.  Before I posted this questions I looked all through the web and found a lot of information.  Unforntunetley I am not familiar enough with command line arguments and there format.  Above, I provided a command line arg example of another type of install.  What I need is the actual argument line that I would use to do what I specified in my question for SQL Express.
Please no more links, but thank you for trying.
0
 
LVL 4

Assisted Solution

by:meenasree
meenasree earned 200 total points
ID: 18754281
SQLEXPR.EXE /qb ADDLOCAL=ALL INSTANCENAME=myInstanceName SAPWD=mySaPassword
0
 

Author Comment

by:Sheritlw
ID: 18754293
Does this make it so that it is a single user and what is instance name.... what you want to name server?
0
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 
LVL 4

Expert Comment

by:meenasree
ID: 18754415
Instance name Specifies the instance of SQL Server to which to connect
0
 
LVL 30

Expert Comment

by:nmcdermaid
ID: 18761569
To make it single user, install SQLExpress, create your database, then connect using SQLCMD (a command line tool) and submit this SQL:

ALTER DATABASE <yourdbname> SET SINGLE_USER WITH ROLLBACK IMMEDIATE

You can't make the entire SQL Server single user, only particular databases.
0
 

Author Comment

by:Sheritlw
ID: 18762156
That would be great, but this is a distributed application that people will be downloading from many different software sites.
0
 
LVL 30

Expert Comment

by:nmcdermaid
ID: 18762403
I'm not sure I understand what the issue is. That will do exactly what you want, just put it in your install script.
0
 

Author Comment

by:Sheritlw
ID: 18775568
Hi,

I just can't use another tool to install sql server.  I would have to operate that tool from the command line also, so I am trying to find another way to do everything from my setup.   I currently have the setup downloading, unpacking and installing sql server express. I am looking into a template.ini  (microsoft site) file to set parameters, like single user, instead of download, installing and activing another tool using the command line.  
Any other information that doesn't require me to use another tool would be great.
Thanks.
0
 

Author Comment

by:Sheritlw
ID: 18775570
0
 
LVL 30

Accepted Solution

by:
nmcdermaid earned 300 total points
ID: 18784829
Can't you just script it into your install application?

SQLCMD is installed with SQL Server. So whatever you're using to run the setup for SQL Server can then run this tool to create and manipulate databases.

For example you could have a batch file with two lines:

SETUP /whatever  
SQLCMD whatever


The first line installs SQL The second line runs SQLCMD.

This is of course an oversimplified example.
0
 

Author Comment

by:Sheritlw
ID: 18786071
I have figured it out using the template.ini sample from microsoft.  I can now download, unpack, install and then install sql server using the following command line.
start /wait setup.exe /qb /settings".._TempFolder.."\\SQLXNew.ini
You have been a great help so I am awarding you all the points.

Thanks for all your help
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now