[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 196
  • Last Modified:

Best method for setting up Linked Server for SQL Server in Windows 7 64-bit

I want to set up a linked server to a folder containing text files so Microsoft SQL Server 2012 can access the data in them.  The database is installed locally on a 64-bit Windows 7 machine, which has Office 2003 installed.  As I try various things, I'm noticing that much of the documentation online involves old, deprecated drivers/providers, and many of the online forum discussions involve people who want to make it work with a particular driver/provider, where there seem to be many issues getting this done on a 64-bit machine.  I don't care what driver I use.  If I can just download a driver that works and has the fewest setup problems, that would be ideal.

Based on reading about the errors I've gotten, I've tried setting up different DSNs for 32- and 64-bit, downloading new drivers (but since Office 2003 is installed, only 32-bit drivers could be downloaded), giving all users access to the directory that has the files, giving the SQL Server access to a certain temp directory, etc.

My question, though, is what is the best approach to do this?  Is there some best practice or way to set up linked servers that bypasses the incompatibility between 64- and 32-bit, doesn't make use of deprecated features, and doesn't require wide-open permissions in various temp directories, etc.?  In other words, rather than chasing down a solution to work with a particular driver, is there a better way to do this that's maybe more straightforward and bypasses most incompatibility issues?
0
Newbis
Asked:
Newbis
  • 5
  • 3
  • 3
2 Solutions
 
ste5anSenior DeveloperCommented:
Please define: "Microsoft SQL Server 2012 can access the data in them."
0
 
NewbisAuthor Commented:
I'm talking about setting up a Linked Server in SQL Server 2012.  Once you set one up, you can query the data in the external source (in this case a text file), without using an ad-hoc solution such as openrowset in your query.  In either case (linked server or openrowset), you have to specify a provider.  When I do, it tends to say that it's not registered, etc.  I'm trying to understand what's the best provider to use these days, with the system configuration mentioned above.
0
 
ste5anSenior DeveloperCommented:
I would use SSIS in the first place.  Using OPENROWSET for bulk-imports is ok. I would imagine more problems with a linked server in this case.
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
Vitor MontalvãoMSSQL Senior EngineerCommented:
I think you are confusing Linked Server with ODBC and DTEXEC. The last two requires 32b and 64b versions because they are executables (.EXE files).
Linked Server is an object inside the SQL Server so I don't think it has this 32b and 64b issue.
Also, what you really want to achieve here so maybe we can recommend you another solution.
0
 
NewbisAuthor Commented:
Well, after discussing this with my manager, it looks as if I'll be using SSIS, more based on the fact that that's what they're more comfortable with in terms of supporting.  The reason why I was thinking of Linked Server is that it seemed from my perspective to be easier to support, before I learned that they're more used to SSIS.  SQL Server's documentation recommends Linked Server over bulk import / openrowset for operations that will be performed regularly; those other two options also require ad hoc distributed queries permission, and I want to keep permissions as limited as possible.

This is for a one-off intranet utility that will interact with a SQL Server database that needs to be loaded with new data from text files in a directory every time someone starts the utility.  So looks as if I will have my .NET code kick off the SSIS package as soon as the request comes in.

When I was trying to do it with a Linked Server or openrowset, when calling sp_addlinkedserver or the wizard, I tried some examples using Jet, or MSDASQL and Microsoft Text Driver, or using ODBC, or various other drivers, and it seemed that rather than debug each one I should try to find which parameters would most likely work best.

So in any case, it looks as if this is lower priority now since we're going to SSIS, but if someone does have an idea of what to use with sp_addlinkedserver that actually works on this particular machine, I'd be interested.  Thanks.
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
I need to see how are you creating the linked server.
bcp utility should be more easy for importing data from text files.
0
 
ste5anSenior DeveloperCommented:
This is for a one-off intranet utility that will interact with a SQL Server database that needs to be loaded with new data from text files in a directory every time someone starts the utility.  So looks as if I will have my .NET code kick off the SSIS package as soon as the request comes in.

It still depends on your concrete needs.

I can imagine doing this entirely in the tool and using the SqlBulkCopy Class. Another possibility could be filling an EF object graph and pushing the data to the server.
0
 
NewbisAuthor Commented:
@ste5an:
Thanks for the recommendation on SqlBulkCopy Class.  I like that idea, and might consider it if I have trouble with other ways.  I don't think Entity Framework to connect with the text files would be good, as it seems like too much overhead just to get the data into SQL Server.  But I'm leaning towards SSIS now because then if there's a data problem down the road, they can troubleshoot the package instead of getting into the .NET code.
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
Just for information, bcp stands for Bulk Copy Program. It's an .exe file that receives parameters and depending on that will do the job for you so no need for coding.
0
 
NewbisAuthor Commented:
I ended up using SqlBulkCopy class and it worked like charm.  Earlier, I had tried SSIS but I got another weird installation error and figured I should be getting this written rather than debugging weird errors with my development machine.  They're okay with that too...at least it keeps everything within the same technology and is also relatively low-level vs. doing some sort of EF solution.
0
 
NewbisAuthor Commented:
Although I didn't get an answer to the original question, in the end it doesn't matter. SqlBulkCopy does what I needed, and it's working now.  I like the fact that I don't have to worry about what's installed properly on my machine and get just get something up and working.  thanks.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

  • 5
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now