SSIS - how to make a connection string for your database server? - sql-server

How do i make a connection string for my database server ? I want to know this so that i can save connection strings in a table and then use them later. Note - All my database servers don't need password and username. I login to a remote "mother" server and access the other remote servers in management studio using 'windows authentication'. So, i don't think my connection string needs to have a user name and password.

Assuming this is for SSIS, create a connection manager, then poke around in it's properties - you'll find the connection string. Take a look here for examples:
http://www.connectionstrings.com/

When connecting to an MS SQL database you require to log in using an account. I am assuming that the windows account you use to connect to the remote server is also the account that is used to log into server is the same account that is used to log into the server. So you can set a connection manager using the same window authentication.
To set up a new connection from BIDS open the solution manager window, then one right hand mouse click on 'Connection Managers' and left hand mouse click on 'New Connection Manager'
The 'Add SSIS Connection Manager' window will appear, this example l have selected and OLE DB connection, next click on the 'Add..' button.
The next screen may already have connections defined as the screenshot shows. Press the 'New..' button to add another data connection.
This final screen is where you provide the details of the database you wish to connect to. The combo box titled 'Server name' when you click on the down arrrow, may contain the server\database instance you want to create a connection for. Otherwise you can enter it manually by typing it directly in the the box. The syntax is as follows [database server name][MS Sql server instance name] eg Yoda\LukeDB. Where 'Yoda' is the name of the server and 'LukeDB' is the name of the database instance you want to connect to. In the screenshot the 'Log on to the server' is set to 'Use Windows Authentication'. However this assumes the windows account on you access the remote server with is the same as the machine running the SSIS package. Once you have entered all the details, press 'Test Connection' to check if a connection can be made successfully.
From a security point of view it would be recommended to set up a SQL account on the database instance which the SSIS package is run against. Then configure that SQL account just the permissions it requires to run the SSIS package.

Related

Finding Connection Information for MS SQL Server

So I just downloaded Microsoft SQL Server 2019 (Developer) and the Server Management Software as well. I am trying to connect one of this new server's databases to an IntelliJ IDE Project, but I don't know where to find the connection information from.
Here is the IntelliJ DB connection page with the information
This is the information I need. I'm a CS student and took a 4000 level class before taking Design of Database systems. I'm sure I can make it work once I get the connection working, its just JSF and JDBC and SQLJ project.
So for anyone connecting a SQL Server for the first time to IntelliJ using Microsoft SQL Server Management and Microsoft SQL Server I will leave this:
Go to Windows search type Services
Navigate down to SQL Server Browser, right click Properties
Change startup type to automatic, under Service Status click Run
Go to MSSM, under Security enable Windows authentication and Server authentication
Go to SQL Server Configuration program from search
Make sure Server Browser is running, go to SQL Server Network Configuration (not 32-bit)
Click the arrow, go to Protocols for SQLEXPRESS (You may have a different name of SQLxxx if you downloaded another version than EXPRESS)
Enable TCP/IP by right-clicking enable
Right click and select properties
Under general, make sure Enabled is set to Yes, then go to Ip addresses. Scroll all the way down to IPAll
Set Dynamic Ports to blank, and TCP port to 1433. Restart your server.
In MSSM, under Security, create or change a login. SA is system admin, change the password if you want, or create another user by right clicking logins and adding if you want.
If you use sa, (I called it SA earlier I mean the same thing) make sure you right click go to properties status and make sure login is enabled. You can close out, and restart program, use Windows or Server authentication, if you want to use sa choose server authentication, then enter sa for user and whatever pass you made.
Now in intellij click the database pane. Choose a Microsoft SQL server, and the url by default is jdbc:sqlserver://localhost;instance=SQLEXPRESS. Enter your user credentials, Windows auth or server auth, and make sure you click the text at the bottom that says to download the drivers.
^Note, this will change if you didn't use SQLEXPRESS, change the name to your instance name in MSSM, right click the server and check properties instance name.
15. Choose your authentication type, I used SA.
To use DB with JDBC or SQLJ, JSF etc, import java.sql.*; and use the following lines
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:sqlserver://localhost;instance=SQLEXPRESS; databaseName = surveyData; user = sa; password = xxxxxx;";
Connection con = DriverManager.getConnection(connectionUrl);
Use your user and password, and databasename in the String connectionUrl. I think the drivers for JDBC:ODBC are installed already at this point, but if not, Google jdbc Microsoft SQL Drivers and download from official Microsoft site. It has various drivers for different Java Runtimes, so locate yours matching your Project SDK and add it to libraries. (the specific .jar in the folder)
The connection should work. If you want to test your connection make a main and type something like
if(con != null)
System.out.println("Connection successful");
Hope that can help someone in their coursework.

SQL Server Login Across LAN

I have an Access front-end on physical box A linked to a SQL Server instance in physical box A. When I launch the FE, it automatically connects to the SQL Server database with no issue. However, when I launch the same FE from networked physical box B, I get a "login timeout expired" error. I click "OK" which opens the generic SQL Server Login dialog, I click "OK" and I'm immediately connected. Any ideas? Thanks!
Well, first up, are you using sql logons, or windows logons?
I would on that 2nd machine re-link the tables. And you VERY much want to do make the connection with what we call a FILE dsn. If you do this, then if that instance of SQL server is open and allows incoming connections, then it should work.
So re-link the tables - in fact I recommend that you delete the table links. And AS stated you MUST use a FILE dsn - not machine/user. So, you can setup this link on the dev box that has both access + SQL server - but you REALLY need to use SQL server logons - not windows based logons.

What setting has to be done to connect with database with this connection string given below?

In my .exe setup having connection string
Data Source=SERVER;Initial Catalog=POS_Chimur;User ID=sa;Integrated security=false
I have to install database for this exe what settings will be needed according to above connectionString.
Till now I have installed sql server with default instance with name of pc SERVER. Still i am unable to connect with above connection string.
You need to cheat your way in. Here's how I would approach this problem:
Data Source=SERVER;
You can create an alias to point to your final instance using "SQL Server Configuration Manager", "Aliases"
Initial Catalog=POS_Chimur;
You need to have a database named POS_Chimur
User ID=sa;Integrated security=false
Here, you need to provide a SQL login named sa with no password. I recommend to rename actual sa account to original_sa then create a new account named sa with no password. You also need to create a user mapping for that new account in the POS_Chimur database using this code.
CREATE USER sa FOR LOGIN sa;
ALTER ROLE [db_owner] ADD MEMBER sa;
If DBO doesn't work then you can give it SysAdmin rights if you still have error.
If you are using SQL Server security, you need to specify a username and a password, like this (where you replace 'mySApassword' with the actual password):
Server=SERVER;Database=POS_Chimur;User Id=sa;Password=mySApassword;
In the event you want to use Windows security, you will need this connection string:
Server=SERVER;Database=POS_Chimur;Trusted_Connection=True;
If you are running the executable on the same machine as where SQL Server is running, you can replace 'SERVER' with '.' in order to make it work on all computers, if you need to distribute it to more than one pc.
Here's some more information about SQL Server 2008 connection strings.
I see two things mainly:
You are connecting with SQL Server login
Go to SQL Server Management studio
Connect to the database server with administrative account you know and that works
right mouse click on the server in the 'Object Explorer' window
choose security
In the Server authentication group, choose 'SQL Server and Windows Authentication mode'
Restart SQL Server
This account is sa and doesn't have a password
Go to SQL Server Management studio
connect to the database server with administrative account you know and that works
unfold the server object [-]
unfold the Security folder [-]
unfold the Logins folder => find sa login
right click on it and click Properties
In General section uncheck the Enforce password policy checkbox and clean the passwords in both text boxes
In Status section, make sure that Login is Enabled and that the Permissions to connect is set to Grant
click Ok
confirm, that you want to create a login with blank password (which is obviously always a risk)
After performing those steps, please log out, and try to log in again, but change the Authentication drop down value to 'SQL Server Authentication' and try to login with sa and empty password, if it works, then the connection string should be fine too.
You need to mention the Provider. Your connectionstring should look like this.
Data Source=SERVER;Initial Catalog=POS_Chimur;User ID=sa;Integrated security=false; Provider="System.Data.SqlClient"

create database permission denied in database ‘master'-sql 2008 R2

So I have installed SQL Server 2008 R2 on windows 7 machine.I was able to login using my windows authentication.Now when I try to create a new database it gives me this error saying "CREATE DATABASE permission denied in database ‘master'".I have tried so many links related to this issue but still it is failing.These are the options that I tried:
1) Went to SQL Server Configuration Manager and then changed the parameters in the advanced tab by adding -m.It still did not help me.When I add this parameter and try to login again using windows authentication it gives me a message saying "Only one administrator can login as it is in single user mode".
2) While Installation I am sure that I added the current user under sysadmin role. I also made sure that the "Mixed mode authentication" is selected and then gave a password for the user "sa".Now when I try to use that password it says "Failed login for user sa".
3) When I login with windows authentication and then check the login mode by following this:
right click on main instance name-->Properties-->Security,it shows that only windows authentication mode is selected.But I am very much sure that I selected the "Mixed mode authentication".Not sure why it is showing it in this way.
4) I also tried to modify the password for sa but the current user has no permissions.I am not able to perform any operation with this user.
I know there are different links for this issue.But I tried all the options that were mentioned in those links but still it is giving me a problem.I have been trying to resolve this issue from a very long time.Could anyone suggest what I am missing here.
Solved! I had the same problem. I figured it out based on info from the article and the comments from the first commentor in this link.
I'll copy the author's steps with the necessary modifications in bold:
Open the Configuration Manager tool from the "SQL Server 2005| Configuration" menu
Stop the SQL Server Instance you need to recover (both SQL Server AND SQL Server Agent. Once in single user mode, if not stoped, the agent will tie up the connection, preventing you from using it with sqlcmd.exe).
In SQL Configuration Manager, click on SQL Server Services on the left, then right click on SQL Server on the right, navigate to the “Advanced” tab (or "Startup Parameters for more recent versions of SQL), and in the Properties text box add “–m” to the end of the list in the “Startup parameters” option.
Click the “OK” button and restart the SQL Server Instance (just SQL Server. Do not restart the SQL Server Agent just yet.) NOTE: make sure there is no space between “;” and “-m”, the registry
parameter parser is sensitive to such typos. You should see an entry
in the SQL Server ERRORLOG file that says “SQL Server started in
single-user mode.”
After the SQL Server Instance starts in single-user mode, the Windows Administrator account is able to connect to SQL Server using
the sqlcmd utility (it is probably here, or someplace very similar: C:\Program Files\Microsoft SQL Server\110\Tools\Binn\SQLCMD.EXE) using Windows authentication. You can use
Transact-SQL commands such as "sp_addsrvrolemember" to add an existing
login (or a newly created one) to the sysadmin server role. The
following example adds the account "Buck" in the "CONTOSO" domain to
the SQL Server "sysadmin" role: EXEC sp_addsrvrolemember
'CONTOSO\Buck', 'sysadmin'; GO
Restart/Start SQL Server Agent, back in the SQL Server Configuration Manager.

SSIS - Transfer SQL Server Objects Task - Problems with SMO Connection Manager

I am using SSIS within Visual Studio 2012. I am planning to use the Transfer SQL Server Objects Task in SSIS to, well, transfer (nearly) all objects (schema only) between servers. I am unfortunately stuck at the SMO Connection Manager configuration step. While in the Editor for the task, I click on Source Connection and select <New Connection ...>. I then enter the name of the server I wish to use as the source. When clicking on Test Connection, I get a Failed to Server error message. I am able to connect to the server from SSMS, and I can make a successful connection if I create a Connection Manager in SSIS. I simply cannot successfully connect when using the SMO Connection Manager within the Transfer SQL Server Object Task.
It's probably already too late, but I've realized that if you don't click on Test Connection and leave the Server Name, you can click OK, and when you hit the dropdown on SourceDatabase, the list of DBs appear.
In my case the solution was to enable TCP/IP protocol for instance (I was trying to connect to) in Sql Server Configuration Manager and in Properties of protocol on tab IP Addresses for IPAll set TCP Port to 1433.
I have just came across the same issue one hour ago in VS2012. There is a bug related to Visual Studio, which gives you this error message regardless the network connection when you add SMOServer type of connection and press Test Connection button before pressing OK button.
Therefore, what you need to do is to add SMOServer Connection, select your source and press OK without testing the connection. Then you can test the connection after making a right click and edit on the connection manager. The test works when you do in that way.

Resources