sqlcmd not working after installing sql server 2005 express - sql-server

I downloaded the 53.5 MB setup of SQL Server 2005 Express from this URL:
Microsoft SQL Server 2005 Express Edition
Then I ran sqlcmd by going into command promp , but it shows error
HResult 0x2, Level 16, State 1
Named Pipes Provider: Could not open a connection to SQL Server 2.
Sqlcmd: Error: Microsoft SQL Native Client : An error has occurred
while establishing a connection to the server. When connecting to SQL Server 2005,
this failure may be caused by the fact that under the default settings SQL Server
does not allow remote connections..
Sqlcmd: Error: Microsoft SQL Native Client : Login timeout expired.
Then I downloaded and installed Sql Command Line Utility from this URL:
Feature Pack for Microsoft SQL Server 2005 - November 2005
Then also it shows the same error.
Then I installed Sql Native Client, then also it didn't work. But when I installed Management Studio, then from Management Studio the connection is established, but not from sqlcmd from Command Prompt.
Please help.

"Just typing sqlcmd on its own won't work - how should the utility know what server to connect, what database to use, and what command to run??"
Funny thing. As I read the Microsoft documentation, just typing sqlcmd while sitting on the server should open a connection to this server. At least it can, depending on settings for security. Typing sqlcmd without any options for login/security may very well fail, but the utility will defintely try.
And SQLCMD without quit is just that, right?

What if you do something like:
sqlcmd -S W\SQLEXPRESS -E -d master -q "select * from sys.tables"
Just typing sqlcmd on its own won't work - how should the utility know what server to connect, what database to use, and what command to run??
You need to tell sqlcmd what you want to do! Get a list of its command options using sqlcmd -?, study them, and use them! Or read the MSDN docs on Using the sqlcmd utility with SQL Server Express - btw: searching MSDN for answers and documentation would be a good idea for all your SQL Server problems......
The SQL Native Client is definitely needed, yes - not sure what you mean by the second package there.

Related

How to find a list of local MS SQL Servers?

I looked at How can I determine installed SQL Server instances and their versions? already but CMD returns nothing:
C:\Windows\system32>sqlcmd -L
C:\Windows\system32>
But when using Visual Studio (v2019), I go to View > SQL Server Object Explorer, I see two SQL Server instances with system databases inside. One is called (LocalDB)\MSSQLLocalDB and the other (LocalDB)\ProjectsV13.
Both are using SQL Server 2016 (v13.0.4001). Using that I was able to connect through SSMS 2018 as well.
My question is: why aren't these instances showing up in the command line? And can I delete one of the server instance? Why are there two?
Using SSMS, in the connection manager typing the following in the server name box does it:
.
open cmd and type hostname, and use that
(LocalDB)\MSSQLLocalDB
(LocalDB)\ProjectsV13 I think this depends on the installation

SQL Server PowerShell dir

I started to learn PowerShell. When I run
PS SQLSERVER:\sql> dir
I got this error:
WARNING: Could not obtain SQL Server Service information. An attempt to connect to WMI on 'DESKTOP-EGEQJFS' failed with the following error:
An exception occurred in SMO while trying to manage a service.
Failed to retrieve data for this request.
Invalid class
Any ideas?
It looks like you're using the SQL Server version of PowerShell. This is intended for performing advanced administration tasks with SQL Server and is not intended as a learning environment.
You're getting the "WARNING: Could not obtain SQL Server Service information" error message because the computer you're attempting to run the SQL Server PowerShell on does not have SQL Server installed or your Windows User account does not have permission to access the SQL Server's configuration data using WMI. If you have SSMS (SQL Server Management Studio) or SSDT (SQL Server Development Tools) installed you won't necessarily have SQL Server installed.
If you want to learn how to use PowerShell then use the Windows PowerShell, not the SQL Server PowerShell. You can find the Windows PowerShell under Start Menu > Windows PowerShell > Windows PowerShell. I recommend using the "PowerShell ISE" tool because it provides a GUI with a listing of all loaded Cmdlets.

Migrate a SQL Server database to a lower version

I am trying to downgrade a SQL Server 2014 database to a lower version (SQL Server 2012) by using the task Generating scripts found when right clicked on the database.
After I make the settings in order to generate the script, the server does that but when I'm trying to open the file (the script made) on a lower version instance of SQL Server, I get the following error.
System out of memory exception thrown
Could anyone provide some help? Thanks!
As suggested by #usr you can run the script from the command line using sqlcmd:
sqlcmd -S myServer\instanceName -i C:\myScript.sql
Alternatively you can download a trial edition of ApexSQL or Redgate SQL Compare (assuming you have not tried them already) and script over the changes using these tools.
The script is too big for SSMS (a shame!). Run it using SQL Server command line tools.
I find it easier to do this by using Redgate SQL Packager or the two compare tools. They can execute enormous scripts.

Remote Procedure call failed with sql server 2008 R2

I am working with SQL Server 2008 R2. I am unable to connect to my database remotely. I got the following error.
A network-related or instance-specific error occurred while establishing a connection
to SQL Server. The server was not found or was not accessible. Verify that the instance
name is correct and that SQL Server is configured to allow remote connections.
(provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
I have checked the SQL Server properties and I enable the Allow remote connections.
I have checked the Service manager and SQL Server service are running.
I have checked the configuration manager, I can't see any services under SQL Server Services
and it shows Remote Procedure call failed
So please guide me.
Open Control Panel > Administrative Tools > Services > Select Standard services tab (under the bottom) > Find start SQL Server Agent
Right Click and select properties,
Startup Type : Automatic,
Apply, Ok.
Done.
I just had the same issue and was able to solve it by installing Service Pack 1.
This error occurs only after I have installed the Microsoft Visual Studio 2012 setup in my work machine.
Since it is being a WMI error, I recompiled the MOF file –> mofcomp.exe "C:\Program Files (x86)\Microsoft SQL Server\100\Shared\sqlmgmproviderxpsp2up.mof"
I also un-registered and re-registered the sql provider DLL –> regsvr32 "C:\Program Files (x86)\Microsoft SQL Server\100\Shared\sqlmgmprovider.dll" but issue not resolved.
Solution:
I have applied SQL Server 2008 R2 SP2 on my SQL 2008 R2 instance and that fixed the issue with Sql Server Configuration Manager. You can download setup from here... http://www.microsoft.com/en-us/download/details.aspx?id=30437 .
After trying everything between Stackoverflow and Google, I finally found a solution : http://blogs.lessthandot.com/index.php/datamgmt/dbadmin/remote-procedure-call-failed/
TL;DR :
If you are (or were) running multiple versions of SQL Server on your machine, that Configuration Manager shortcut on your start menu might be pointing to an older version, which it shouldn't be. It was pointing to an old Sql Server 2008 instance in my case.
The solution was to :
Go to either C:\Windows\SysWOW64 or C:\Windows\System32, depending on your system.
Look for an executable called SQLServerManagerXX.msc, and run the latest version if you have multiple ones. In my case, I had both SQLServerManager11.msc and SQLServerManager10.msc, where the 10th gave the error, and the 11th worked perfectly.
I can't comment yet, but make sure you made all the checks in this quide: How to enable remote connections in SQL Server 2008? It should work fine if all steps are made.
Upgrade your SQL Server to SP3
You can install it from:
http://www.microsoft.com/en-us/download/details.aspx?id=27594
This error appears to happen when .mof files (Managed Object Format (MOF)) don’t get installed and registered correctly during set-up. To resolve this issue, I executed the following mofcomp command in command prompt to re-register the *.mof files:
mofcomp.exe "C:\Program Files (x86)\Microsoft SQL Server\100\Shared\sqlmgmproviderxpsp2up.mof"
This one worked for me
start SQL Server Agent from the command prompt using:
SQLAGENT90 -C -V>C:\SQLAGENT.OUT
You might need to install SQL Server 2008 SP3.
SQL Server 2008 Service Pack 3
SQL Server 2012 Configuration Manager WMI Error – Remote Procedure call failed [0x800706be]
I got the samilar issue, while both SQLServer and SQLServerAgent services are running. The error is fixed by a restart of services.
Server Manager > Service >
SQL Server > Stop
SQL Server > Start
SQL Server Agent > Start
Open Control Panel
Administrative Tools
Services
Select Extended services tab
Find SQL Server(MSSQLSERVER) & SQL Server(SQLEXPRESS)
Stop these services and Start again (from the start & stop button displayed above)
Done.

SQL Complains that Management Tools are not installed, but they are

When I try to create a new Maintenance Plan in SQL Server, I get the following warning:
The action you attempted to perform on
a remote instance of SQL Server has
failed because the action requires a
SQL Server component that is not
installed on the remote computer. To
proceed, install SQL Server 2005
Management Tools on the remote
computer, and then try again. For more
information, see "How to: Install SQL
Server 2005 (Setup)" in SQL Server
2005 Books Online, or find the article
on MSDN at
http://go.microsoft.com/fwlink/?LinkID=57083
. (ObjectExplorer)
However, the tools are installed, AFAIK. I'm connecting to the local machine. Here's a screenshot of both the error message alongside SQL Server telling me it won't install the management tools because they are already there.
(previous step here)
Any ideas?
Ah - nevermind on this. The response is simply a bit misleading. It's only complaining about part of what I was asking to install. When I decided to progress, it did in fact install some things.

Resources