How to connect to a SQL Server database from local pc? - sql-server

I am a Crystal Reports developer and I have always been working with Oracle database and this is my first time with SQL Server.
This is what I have been desperately searching for.
From my local PC, I want to connect to a SQL Server database which is on a database server.
I am aware that I need a 'SQL Server Native Client'. And I am also aware that I need to use 'sql server management studio' so that I can view the tables and writes queries instead of using a tool like TOAD.
My questions are:
Can I use 'Microsoft SQL Server Management Studio Express' from my local PC to connect to a SQL Server 2005 Database in a database server?
If I install 'Microsoft SQL Server Management Studio Express' do I still need to install a 'SQL Server Native Client'?
Thanks,
rivi

Can I use 'Microsoft SQL Server Management Studio Express' from my local PC to connect to a SQL SERVER 2005 Database in a database server?
Yes.
If I install 'Microsoft SQL Server Management Studio Express' do I still need to install a 'SQL Server Native Client'?
If you want to connect to the database from your application you will need it installed. It should be installed as part of the SSMS install.

Answer 1:
SQL Server Management Studio can be used to manage either local or remote SQL database server.
If you installed SQL Server Express, the default instance will be SQLExpress. To connect it locally using Windows Credential, just type .\SQLExpress or yourmachinename\SQLExpress in the server name textbox.
If you host the SQL Server on a remote server, you must use the credential given by the authority hosting your SQL Server. It is easy, ask your admin for the details.
Answer 2:
See this for the details
I copy and paste the important notes from the link above here:
When deciding whether to use SQL Server Native Client as the data access technology of your application, you should consider several factors.
For new applications, if you're using a managed programming language such as Microsoft Visual C# or Visual Basic, and you need to access the new features in SQL Server, you should use the .NET Framework Data Provider for SQL Server, which is part of the .NET Framework.
If you are developing a COM-based application and need to access the new features introduced in SQL Server, you should use SQL Server Native Client. If you don't need access to the new features of SQL Server, you can continue to use Microsoft Data Access Components (MDAC).
For existing OLE DB and ODBC applications, the primary issue is whether you need to access the new features of SQL Server. If you have a mature application that does not need the new features of SQL Server, you can continue to use MDAC. But if you do need to access those new features, such as the new xml Data Type, you should use SQL Server Native Client.
Both SQL Server Native Client and MDAC support read committed transaction isolation using row versioning, but only SQL Server Native Client supports snapshot transaction isolation. (In programming terms, read commited transaction isolation with row versioning is the same as Read-Committed transaction.) For more information, see Choosing Row Versioning-based Isolation Levels.
For information about the differences between SQL Server Native Client and MDAC, see Updating an Application to SQL Server Native Client from MDAC.

Related

A Common ODBC Connection Strings works for SQL Server 2005+

I am using CDatabase in VC2008 to connect to SQL Server via ODBC.
I want to use a common connection string that can work for SQL Sever 2005 and all higher versions.
I check https://www.connectionstrings.com/microsoft-sql-server-odbc-driver/ and see there are many different kinds of connection strings.
Whether I should use:
Driver={SQL Server};Server=myServerAddress;Database=myDataBase;Uid=myUsername;
or
Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase;
Uid=myUsername;Pwd=myPassword;
Pwd=myPassword;
Update:
Based on my test, using Driver={SQL Server} or Driver={SQL Server Native Client 10.0} can both connect to SQL Server 2008. I guess the former will works for all SQL Server versions, but the latter will only works for SQL Server 2008. Please confirm my guess.
Both driver will connect to Sql Server.But purpose of both drivers are different.
Driver={SQL Server} :
It is called Windows Data Access Components (WDAC).
It do not support new feature of Sql server 2005+ like xml data type,Multiple active result sets (MARS), user-defined data types (UDT), query notifications etc.
It support only Read Committed transaction isolation.
Driver={SQL Native Client}
This driver is suitable for application that need to take advantage of new feature of Sql server 2005+.
It support both Read Committed transaction and snapshot transaction isolation level.
System.Data.SQLClient
SQLClient is optimize for .NET and database Sql server 2000+.
It give maximum performance.
So if your application is new or existing then use SQL Native Client.It can access all feature of connected version of Sql server 2005,2008 etc.
ODBC :Use ODBC when application is connected to multiple database or it is expected that database may change.DAL code is written in such a manner it will work for any database.
Suggested Reading
Common Connection : I don't think there can be any common connection.Suppose in my system SQL server native client 10 is install then I know that I cannot connect to Sql server 2016 + .SQL server native client 10 will work for Sql Server 2016 and below.
Of course by programming we can make dynamic connection string which will accept driver as parameter etc.
To connect to higher version ,s I will hv to upgrade my driver and do minor change in connection string.Or if you don't want to touch code then Use DSN.
Yes I forgot, Driver={SQL Server Native Client} it can connect to Sql Srver 2005 only.if you try to connect to higher version then it will throw error.

Syncing a SQL Server CE database with a regular SQL Server database

There's an Umbraco site that various people been contributing content to. It runs on a hosted domain using a SQL Server Compact edition database for the CMS. It's about to go live and I need to sync the dev database to the live SQL Server instance which is hosted by a third party.
I just ass(u)me(d) that I could attach the .sdf to my local SQL Server and use a commercial tool (Redgate/SQLDelta etc.) to copy it to the live db. This does not seem to be possible. While I have managed to attach the .sdf using Linqpad, I can't connect to it like a regular database.
The best option seems to be to script out the entire database, but this seems like an impossible task using just Linqpad (no flies on Linqpad, obviously - it isn't the tool for such a task). Any less onerous options would be gratefully accepted.
You can use my free "SQL Server Compact Toolbox" Visual Studio extension for this. It can generate a script of the entire SQL Server Compact database, that you can then run against an empty SQL Server database.
In the past I did this kind of scenario wherein I need to copy the data from the SQL Server CE to a SQL Server database. Have you tried adding the .sdf to an ODBC then linked that ODBC to SQL Server?

confusion about SQL Server Express and localdb

I need to deploy a WCF service with a database on client machines. I am confused about SQL Server Express. I need to verify all of the following.
When attaching database files in the App_Data folder, do I still need to install SQL Server Express engine (Windows service) on client machines?
There is a flavor called SQL Server Express LocalDb. That one does not need an engine (Windows service)? But I think it need a prerequisite installation of LocalDb.
Localdb is introduced with SQL Server 2012. There is NO localdb for SQL Server 2008. Correct? I could not find 2008 version on MS site.
Do I still need to install SQL Server Express engine (A win Service)
on client machines?
Yes, they need it installed for your application to query the database. Can't really get around it.
There is a flavor called SQL Express localDb. That one does not need
an engine (win service)? but I think it need a perquisite installation
of localdb.
Yes, you'd still need to install LocalDB on the client machine. It's pretty hassle-free to do, but I think it's overkill unless you really need the full features of a SQL Server instance for your webservice.
Instead of LocalDB I'd strongly recommend using SQL Server Compact Edition - it performs the role you're thinking of (your WCF Service can simply connect directly to the database file on your client machines without installing SQL Server, and is lightweight), but doesn't need to be installed (it's simply included as a DLL with your WCF application):
Unlike other editions of Microsoft SQL Server, SQL CE runs
in-process with the application which is hosting it.
In Microsoft's own words on the differences between LocalDB and SQLCE:
LocalDB and SQL Server Compact?
Small and simple database, lightweight installation, connecting to a
database file -- this will sound familiar to any developer using SQL
Server Compact. The similarities are not accidental, as our goal for
LocalDB was to be as easy to use as SQL Server Compact (while being as
powerful and compatible with full SQL Server as SQL Express).
There are significant differences between LocalDB and SQL Server
Compact:
Execution mode: SQL Server Compact is an in-proc DLL, while LocalDB runs as a separate process.
SQL Server CE is kind of like an updated version of MS Access, the file goes with the application which can "just connect" to the database file without involving any database server installation, and its syntax/features are very close to SQL Server standard.

SQL Server Express usage with Pentaho (or any non-microsoft product)

I'm trying to connect a local SQL Server database to an ETL utility called Pentaho. Pentaho very easily connects to full versions of SQL server without issue.
I've set mixed mode authentication and created a sql server account for the sql server express instance that can be used to login through SSMS.
When I try to log in via Pentaho, I get errors about it not knowing what the server is, or the server not responding. I've tried {localhost, myip, localhost\SQLEXPRESS, myip\SQLEXPRESS, just SQLEXPRESS} as the server name (and SQLEXPRESS is the instance name).
I know I've had trouble connecting other programs to SQLEXPRESS databases in the past. Can someone tell me why it acts different than when using a full install of SQL Server and how I can get around these differences?
If SQL Server Express is on a different server, have you enabled TCP/IP protocol?

Crystal Reports, which OLEDB provider to use for SQL Server

When designing a new Crystal Report you have to create a new database connection. I have selected OLE DB (ADO) as the 'driver' as it made more sense than DAO,RDO or the other options for my requirements.
I need to execute an SQL Server 2005/2008 stored procedure on a remote server and show the results in Crystal Reports on a .NET client.
Selecting OLE DB, presents me with further options to select the correct provider, some of which are:
Microsoft OLEDB provider for ODBC drivers
Microsoft OLEDB provider for SQL Server
SQL Native Client
SQL Server Native Client 10.0
Which on is the best to use?
I don't want to use the ODBC drivers, for various disadvantages (setting up ODBC definitions and maybe slower).
Not sure how the OLEDB provider for SQL Server compares with the native client
The native client forced me to run the native client setup on each desktop. It also seems that there is different version for each version of SQL Server.
Initially I thought the native client is the logical choice for compatibility and performance but deployment seems to be an issue (unless I am doing something wrong)
What is the best connection driver/provider combination to use here?
I would go with the Microsoft OLEDB provider for SQL Server. If you use the native client, you will need to distribute it with your applications.
This article talks about the native client in detail: http://blog.flex2sql.com/index.php/2009/02/how-and-when-to-use-sql-server-native-client/

Resources