Creating new user in SSMS with dialog box [duplicate] - sql-server-2017

I am running SQL Server Management Studio v17.6.
The online tutorials for creating a new Login show a dialog that comes up when your right-click on Logins and select New Login.
I don't see this dialog; instead I get a script to CREATE LOGIN which is OK but I would prefer the dialog.
I don't see an option to switch from getting a script to getting the dialog. I don't know if this version does not have the dialog or if I am just not finding the option.

Currently this is an Azure SQL limitation.
More information can be found here on azure.microsoft.com or here on Microsoft docs.
When creating a new login with the following SSMS menu item:
this is what appears with an Azure SQL database:
instead a dialog window appears when using a local database:

I also found a helpful post that explains the limitations at the time of this post.
Azure SQL limitations
What I did was inside SSMS, while connected to your Azure SQL instance, make sure you are first connected to the master database as shown:
Then run this script with your values against the master DB.
CREATE LOGIN WorldCitiesLogin
WITH PASSWORD = N'<your_password>'
GO
Next, switch your instance in SSMS to the database you want to map your login:
Then, run this script with your user name that maps to the newly created login above:
CREATE USER WorldCitiesUser
FOR LOGIN WorldCitiesLogin
WITH DEFAULT_SCHEMA = [dbo]
GO

Related

Linked Server failing on SQL Server job

I have a linked server that perfectly works when executing a query. But when I place the query in a job, it fails.
Here is the setting of my linked server
Error
Read SQL Server Agent job fails when the job uses a linked server.
WORKAROUND To work around this problem, use one of the following
methods:
Method 1
Make the system administrator the owner of the job.
Method2:
Use mapped security context for the linked server and modify the job
to run as OSQL.
To set the mapped security context for the linked server: Right-click
the linked server, and then click Properties. Click the Security tab.
Select either of the following options. Be made using the login's
current security context Be made using this security context To modify
the job to run as OSQL: Right-click the job, and then click
Properties. In the Steps tab, click the Step Name that you want to
edit, and then click Edit. On the General tab of the Edit Job Step
dialog box, click Operating System Command (CmdExec) in the Type list.
In the Command text box, type osql –E –Q “Exec storedProcedure”. In the Edit
Job Step dialog box, click OK. In the Properties dialog box, click OK.
In linked server definition tick:
Be made using the login's current security context
I had this same issue, And after changing user permissions etc etc etc, I found this article and instead of using "Be made using the login's current security context" i used "Be made using this security context" and i specified the account and password which solved the issue. So the issue isnt with SQL jobs or my procedure it was in actual fact my linked server. Even though the link server did work... When calling a linked server within a SQL job the linked server had to have the account details specifically specified.

Assigning 2 users to a single database in MSSQL SERVER2008

Please let me know the steps to add 2 users in a Single database on SQL server 2008
Tried adding user to same database in security but unable to access database.
One user is working fine after adding into the database.
If you have Microsoft SQL Server management studio installed:
In SQL Server Management Studio, open Object Explorer and expand the Databases folder.
Expand the database in which to create the new database user.
Right-click the Security folder, point to New, and then click User.
On the General page, enter a name for the new user in the User name box.
In the Login name box, enter the name of a SQL Server login to map to the database user.
Click OK.
If not use these commands
USE <database name> GO
CREATE USER <new user name> FOR LOGIN <login name> ; GO

Adding First Login to SQL Azure Database

I'm trying to create a SQL Azure database. While the database successfully gets created, I can't login to it. The reason why is, I don't know what the default username / password is. Or, how to create the first user that can access the database.
There has to be something basic I'm missing here. How do I create the first user for a SQL Azure database.
The database exists on an Azure SQL Instance. You need the administrative loginid/password you assigned when you created the instance.
When you are in the Azure Management Portal (https://manage.windowsazure.com) go to "SQL DATABASES".
On the "DATABASES" page (along the top), find your database. Look for the name of your databases' server in the "SERVER" column, and click on the link for the server.
On the page for the server, along the right side under "quick glance", you will see the "ADMINISTRATOR LOGIN" and further up you see a link to "Reset Administrator Password". You can reset it if you don't remember it.
Now, you can login using those credentials (admin login/pwd) and create additional logins as needed.
Hope that helps.

Changing the default database for a SQL Azure login

I would like to change the default database for a login to support software that can access SQL Azure but does not allow easy alteration of a connection string. It appears that SQL Azure defaults to the master database.
I've already considered:
Stored procedures. I can't find a stored procedure that does this (sp_defaultdb is not implemented in SQL Azure as far as I can tell)
Alter Login. ALTER LOGIN does not permit the DEFAULT_DATABASE option.
SSMS. SSMS doesn't seem to allow much user control through the interface for SQL Azure.
Ideas?
Connection String:
Server=tcp:[serverName].database.windows.net;Database=myDataBase;User ID=[LoginForDb]#[serverName];Password=myPassword;Trusted_Connection=False;Encrypt=True;
You can change connect default database, when you write 'Database' property at connection string.
SSMS is connect to database box which is option->secont tab at conecct dialog.
In my case I managed to do it by creating a login directly in the master database:
CREATE LOGIN newlogin WITH password='password'
GO
CREATE USER newlogin FOR LOGIN newlogin WITH DEFAULT_SCHEMA=[dbo]
GO
Then I created a user in the database I wanted to gain access to:
CREATE USER newlogin FOR LOGIN newlogin WITH DEFAULT_SCHEMA=[dbo]
GO
At last adding it to a role in the particular database to gain the right permissions:
Alter role db_owner add member newlogin
Hope this works for you too.
As you already discovered the DEFAULT_DATABASE option is not available in SQL Azure. So if you cannot change the connection string of your application in which you would normally specify the database name, you are stuck to master.
However... is it possible to create an ODBC connection, and configure your application to use ODBC? Using ODBC would allow you to specify a default database.
By far the easiest way in SSMS is to use the additional parameters tab and supply the initial catalog, e.g.
You can easily change the default database when loging in with SSMS. Click the Options button on the Login Dialog then click on the Connection Properties tab. In the "Connect to database" box enter the name of your database.
You have to use use following to be able to change "default" Database
Use "SQL Server Native Client 10.0" or higher instead on using "SQL Server as Driver
Use full user id like UserName#AzureConnnectString
For me it is
NorthWind#w6ywertsd8h.database.windows.net
More details here
http://debugmode.net/2011/04/22/connecting-microsoft-access-to-sql-azure/
Another option is to create a mapped user in the master database and the hosted database. This will allow SSMS to connect to the server and use master as the default db, then the user can open the database. I am not a DBA so I do not know the implications of this, but that is how I solved it. My database is just being used for a POC project so it doesn't have many security requirements.

SQL Server 2008: why do I see only system tables when I login ODBC from ACCESS

I am using Access to try to get some links to tables in SQL Server 2008.
I've created a user name under security in SSMS for SQL Server and I've mapped it to a user that is under the database that I need. I've also given that user a default database that I need.
When I try to connect through ODBC I am not seeing the correct tables. What I am seeing is a bunch of Sys tables. Does anyone know what I am doing wrong?
Here is the create for the main user:
/* For security reasons the login is created disabled and with a random password. */
/****** Object: Login [lomuser] Script Date: 10/22/2010 08:14:03 ******/
CREATE LOGIN [lomuser] WITH PASSWORD=N'µ''ØÑëOº\¾dõMÐàæfÄ%[RríÜ2 y', DEFAULT_DATABASE=[LOMDATABASE], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
GO
ALTER LOGIN [lomuser] DISABLE
GO
Here is the create for the specific user to the specific database (on which the top user is mapped to) also FYI they have the same name:
USE [LOMDATABASE]
GO
CREATE USER [lomuser] FOR LOGIN [lomuser] WITH DEFAULT_SCHEMA=[dbo]
GO
When you setup the DSN connection in the odbc panel or let access create this connection for you, the default database is master. So, when you link a table, the only tables you will see are the system tables. Delete your linked table (if you have any). Now, when you choose to link to a table, choose NEW in the data source to create a new DSN connection. During that process, you see the option to change the default database from system to whatever database you want.
Once you change the above default, then when you link a table, you see tables from the above selected database you choose. If you did not set above, as noted, you just going to see the system tables.
You may find a solution in this article at Microsoft support
This is a known bug in SQL Server
Beware of denying Select to the Public
because it has unintended results elsewhere
The solutions can be difficult for a casual SQL administrator.
By default when setting up (importing) a linked table from an (Azure) SQL Server database MS ACCESS chooses master as the default database. You should change this when linking the table:
1-Click Linked Table Manager under External Data tab
2-Click Add button on the right menu bar and choose SQL (Server/Azure), enter a name for the data source (so you can recognize the data source later in the Link Table Manager list of sources), click Next
3-When SQL Server Login wizard prompted, enter the address of your SQL server e.g. for Azure it should be something like this:
<you_server_name>.database.windows.net
Enter your SQL database user and password for login.
Once done, the button Options will be enabled
4-Click button Options and you will see the Database is set to Default. Click on it and choose the database you want. You should see the tables of the selected database and not master