Reference a linked server without specifying server name [closed] - sql-server

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I have a remote server with an SQL Server instance running on it. I can only access it over a VPN, but my users want to be able to connect to it without using a VPN.
I also have SQL Server running on my computer, and would like the users to connect to the remote server through my computer. I have read about linked servers, but it seems like I have to use the server name in each query.
For example:
select * from [192.168.0.45].[tblUser]
I would like other users that use the linked server to only have to use the table name. For example:
select * from tblUser
Additionally, when I use a linked server, I have to use "master" in the connection string, even though that is not my database.

It is unavoidable that you must reference the remote object using a four-part-name, but you can use synonyms to make a remote table look like a local table.
The four-part-name is composed of [The server name].[The remote database name].[The remote schema (usually dbo)].[The remote table name] and all parts must be specified for queries made against linked servers.
You can, however, create a synonym in a local database to avoid having to specify the four-part-name each time you reference the table.
CREATE SYNONYM [synonymName] FOR [four].[part].[name].[here]
For example, you could proxy an entire database by creating synonyms for each table. Something like the following should work:
SELECT DISTINCT 'CREATE SCHEMA ['+TABLE_SCHEMA+'];'
FROM [INFORMATION_SCHEMA].[TABLES]
WHERE TABLE_SCHEMA <> 'dbo';
SELECT 'CREATE SYNONYM ['+TABLE_SCHEMA+'].['+TABLE_NAME+'] FOR [192.168.0.45].['+TABLE_CATALOG+'].['+TABLE_SCHEMA+'].['+TABLE_NAME+'];'
FROM [INFORMATION_SCHEMA].[TABLES];
Running such a script will produce a script which you can run on the server you are using as a proxy to create all of the synonyms.

Related

Are there VPN,API, VPN, SFTP, Cloud or another possibility to build connection between two remote SQL server database? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I'm totally new in SQL Server. But I'm going to work on it from now.
I have been asked to research five methods to copy or access data from one remote SQL server(Location A) to another remote SQL server(Location B).
I found several method to achieve this goal, such as Linked Server, Openrowset
T-SQL function and SSIS(SQL Server Integration Service).
But are there API, VPN, SFTP, Cloud or another possibility to achieve this goal?
Your answer will be really helpful!
You dnt need to access any other method just make sure Location A Ip and port address is open in the firewall.
Also Location B Server should be accessible to location A
Access server You need below details:
ServerName with Port no
Database Id and Password.
Copy the data from A to B please see below:
you can generate the table script from server A run the same script on Table B.
If you want the Table with data from A then during the script
generation in last window where you need to select patch for script
file Just click on Advance option and then their select the Schema
type as Schema and Data then it will generate the Data script as well
for you.

Hiding data in Sql Server 2008 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
Our sql server userid and password is known to a third party who is using our data integrated with his application bypassing us. He also uses the windows authentication to login and gets all the data required from the client side. I need to hide a few columns from others in sql server. I am aware of the data encryption which is not feasible at this stage and there are too many reports to be modified.
Is there a way to open a database connection along with a symetric/asymetric key and then use the same regular sql statements to read the data?
How to block sql server from logging in using Windows authentication?
Try this: Instead of allowin access to a full table, create a view with only the "public" columns, and give thrid party only access to that view. That way they cannot see you sensitive data columns. Blocking SQL to access from windows autentication is easy, only remove the user from the database.

Securing SQL Server for the internet [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I hope this question is not too broad. I am still doing research, but I was hoping to get opinions from some experts. We are a software provider and our flagship software is accessed through a portal - our SQL servers (active-active-passive cluster) are safely nestled behind our firewalls and only accessed via our application. We have a very large client looking to do an offshoot and wants direct read-only access to their database. This is something we have not done before and makes us nervous. I am hoping for some guidelines to securing SQL server for the internet.
I should say that our cluster contains hundreds of client databases, only one of which will be accessed through this internet connection. We are open to adding additional hardware or software layers if necessary. This is SQL 2005.
Thanks all.
Basically you need to get a VPN established between your site and their's. That way you can hook them up to your local network.
The VPN you use should be capable of allowing you to expose access only to the database server itself.
Once you have that, then make sure you setup a specific database user that only has rights to the actual database they need.
If VPN is not an option most firewalls will allow you to setup a policy to a specific inbound ip on a specific port where the remote client static ip has to be in the ip exception list. this way the remote client would only have access to that specific SQL instance. You would then need to create a SQL user only under the "public" server role. then you would need to go user mapping and give that user access to their database only and give them "db_denydatawriter" and "db_datareader" you would probably also want to take away access from listing other databases so that they don't know who your clients are if you use descriptive names for your clients databases. that can be done under securables under securables. you would have to click search and select "this server" The "permision" us called "view any database". of course you would need SQL authentication for this to work. keep in mind that a client that is not experienced in SQL performance could lock tables, indexes, etc... with poor queries. a list of sprocs written by your shop might be the way to go.
here is an example to get you started.
USE [master]
GO
CREATE LOGIN [remoteuser] WITH PASSWORD=N'test', DEFAULT_DATABASE=[CLIENTDB], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
GO
USE [CLIENTDB]
GO
CREATE USER [remoteuser] FOR LOGIN [remoteuser]
GO
USE [CLIENTDB]
GO
EXEC sp_addrolemember N'db_datareader', N'remoteuser'
GO
USE [CLIENTDB]
GO
EXEC sp_addrolemember N'db_denydatawriter', N'remoteuser'
GO
use [master]
GO
DENY VIEW ANY DATABASE TO [remoteuser]
GO

How to backup SQL Server 2012 database to flat file and again restore the flat file [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
Is it possible to backup SQL Server 2012 database to flat file and again restore the flat file to bring up the database?
If you absolutely have to create a flat (text) file instead of a true database backup, you can do it via scripting. In this case, you'd want to script both schema and data, or simply the data if you have no need for a schema script.
Through the UI, this is done via the database scripting interface (right-click the database -> tasks -> generate script). Select the objects you're interested in (or the entire database), then on the 'set scripting options' form, click the 'Advanced' button. Scroll down until "Types of data to script" is visible, then pick either "Schema and data" or "Data Only":
The output will be a SQL script. If you examine the script, you'll see that after the schema definition statements (if you chose to generate these) are INSERT statements to re-create the data.
Be aware, however, that this method is by no means optimal. Records with unusual contents (e.g. characters that will break the insert statement) will not be handled well when you try to rebuild the data.
(Commenters... be aware I am addressing the question itself, not the "why?" which the question begs.)
EDIT: If you want to do this though a maintenance plan, you'll need to use a third-party tool to generate the INSERT statements. There are several: SQLPubWiz is one.
I don't know your experience with SQL Server, so what I normally do is:
go to my DB -> Tasks -> Generate script -> and script the entire database.
This is to save the structure of the db, so you can build it on a new pc.
go again to the DB -> Tasks -> Export Data -> and here I choose as destination Access instead of Flat File, since I have bad experiences with Flat Files.
Once the export is done, I import it the same way as above into my new db on the new pc.
I hope this is helpful.

SQL Server Documentation Generator Tool [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I'm working on a large SQL Server database with no documentation. Is there a good, preferably free, documentation generator tool I can use to get my head around it.
One tool that I'm using more and more to do this sort of thing is LinqPad (www.linqpad.net). This is far more than just a Linq tool. It is very good at allowing you to drill down through table relationships, as long as FK's are properly in place. This tool is free.
On the non-free side, we also use Red-Gates SQL Doc (http://www.red-gate.com/products/sql-development/sql-doc/). Excellent tool.
You might want to have a look at my new (non-free, sorry) tool - LiveDoco - it's a web app that can be installed on an intranet IIS or even on a local IIS server and then you can just use your favorite browser to connect to a SQL Server database and see its structure/metadata, edit object descriptions or even search in DB object names (tables, columns, functions and their parameters etc.) and in the extended properties where the descriptions are usually stored (under “MS_Description”). And finally there is an export feature you can use to export all extended properties to a SQL file that you can run on a different DB of the same/similar structure to import/update your descriptions/notes there.
There is a fully functional (but read-only) online demo at http://www.livedoco.com.
This link will take you directly to the Person.Contact.ContactID column in the AdventureWorks sample DB from MS: http://demo.livedoco.com/livedoco/Explorer?Server=(local)%5Csql2k8xpress&Database=AdventureWorks#/?L0Name=Person&L1Name=Contact&L2Name=COLUMN_ContactID

Resources