Copying a small database in SQL server - sql

I have a small SQL server 2014 database that simply has just 3 tables and some information in them for a school group project and am wondering what the easiest way would be to have a group member be able to access the database rather then manually copying down all the information from each row and column. We wouldnt be changing any information in the database. Thanks.

I would create a database role. After you create the role add each person that needs access to that role then grant that role read access to each table. This way if a person in that group no longer needs access you can just remove them from the role and vise versa.

Since this is a school project I am assuming that the SQL Server database is a local DB and not on a shared server. You could perform a backup and restore where you back up the database on your machine and send them the back up files and they can use them to perform a restore to create the database on wherever.

Related

If a SQL Server Database is read only can I grant a single user write access?

I have a SQL Server database that we are trying to make read-only for everyone except one user. I already went to properties>options>Database read-only = true and set the entire DB to read-only. Now we are finding that one program updates this DB and will not work correctly without being able to do so. Is there a way to leave the whole DB read-only and just grant write to this one single "user"? SQL server 2008 using SSMS 2017.
No, a database that is read-only cannot be written to by any user. You're best solution would be to give read only permissions to all users except this app.

How to make your Server as Linked Server for selected views?

We have a SQL Server 2012 instance which is the database for our security system. Now we have a scenario where we want to allow another team our SQL Server to select certain records, ie we created four views for them for their requirements.
But, we don't want to provide or list all our tables to them but only allow these four views to see and query in our system. As I go through many documents it's clear that we can do it through making our SQL Server as a linked server.
What's the best way to do it through a linked server?
Are the views in a specific schema?
Try to grant the users access to that schema, so that they can only read and see meta from it.
https://learn.microsoft.com/en-us/sql/relational-databases/security/metadata-visibility-configuration
we don't want to provide or list all our tables to them but only
allow these four views to see and query in our system.
You don't need linked server to accomplish this.
All you need is to grant SELECT permission on these 4 views.
When you create a user in a database and don't grant any permission to it, it does not see any user table/view at all. And it will be able to see and query only those objects on which you'll grant the permissions

SQL Server 2012 server role

In my SQL Server 2012 I have created a server role. I would like the server role can alter just one database one the server because I have many database on the server. How can I grant access for alter data in one database on the server?
Thank you in advance,
Nico.
Presumably you have just added the login to the server. Unless you have given the login sysadmin (I presume you have not), you will need to individually set the security per database ie. map the user to the database, e.g.
USE [Database]
GO
CREATE USER [User] FOR LOGIN [User] WITH DEFAULT_SCHEMA=[dbo]
GO
You will need to add the user to Security/Users in the actual database folder. If you want them to read/write data into/from existing tables, give them db_datareader and db_datawriter by right clicking and going to Properties -> Membership. If you want them to be able to create/drop objects in the database e.g. tables, they also need db_owner. They only have the rights for that db.
In addition of what TJB said, please document on : https://msdn.microsoft.com/ro-ro/library/ms178569.aspx

How to copy tables from one db to another? (Sql azure)

Situation:
I have 2 azure database on the same server. All I need is to copy all tables(with data) from one db to another.
How can I make this with query help? I wasn't able to found any answer for it.
I don't think you can do it with query. Check out Import and Export Data program that follows sql management studio. I think it's called DTSWizard.exe. Anyway, it can copy stuff from pretty much any source.
You can use the CREATE DATABASE AS COPY OF command, like this:
CREATE DATABASE destination_database_name AS COPY OF
[source_server_name.]source_database_name
Same-Server Copying
When you copy a database to make a new database on the same SQL Database server, the same logins can be used on both databases. The security principal you use to copy the database becomes the database owner (DBO) on the new database when it is created. After the copy is complete, the destination database becomes a fully functional, independent database. The logins, users, and permissions of the destination can be managed independently of the source database.
Cross-Server Copying
You can also copy a database between two different SQL Database servers that are in the same sub-region or data center. Because the new database is created on a different SQL Database server, it is associated with a different master database. All users in the new database maintain the permissions that they had in the source database. The security principal you use to copy the database becomes DBO on the new database when it is created and is assigned a new security identifier (SID).
For more info, see this link: http://msdn.microsoft.com/en-us/library/ff951624.aspx

How can I ensure a read only user is created for every new database in SQL server 2005?

We create multiple databases in sql server 2005. I would like to make sure that every new database that is created has a specific read only account when it gets created. I know there is a way to write code to do this, but is there a way we can set up a database template of some sort so every time a new database is created the account is automatically added from SQL server side rather than the code side?
If you mean one read-only user account for all databases on a server, you can use this hack:
Create a new SQL Server login
Create a new Database user in model database with db_datareader privilegues.
All new databases use the model db as template, so the user will be available in all databases.
But keep the security issues in mind. ;-)