Moving Database that uses filestream - sql-server-2008

I have enabled filestream, and I create a database in SQL server management studio with a filegroup/filestream.
I want to use the resulting database in visual studio, so I copy over the 2 files (mdf & ldf) and the filestream folder to App_Data.
I get the following error message in VS server explorer:
FILESTREAM feature is disabled.
A file activation error occurred. The physical file name 'C:\Users\User\Documents\Visual Studio 2010\WebSites\FOO\App_Data\fooFilestream' may be incorrect. Diagnose and correct additional errors, and retry the operation.
Could not open new database 'C:\USERS\USER\DOCUMENTS\VISUAL STUDIO 2010\WEBSITES\FOO\APP_DATA\FOO.MDF'. CREATE DATABASE is aborted.
An attempt to attach an auto-named database for file C:\Users\User\Documents\Visual Studio 2010\WebSites\FOO\App_Data\foo.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Any suggestions? This process works fine with databases that don't use a filestream.

Ok, so here is the issue: MS Visual Studio cannot connect to a database as a file when that database makes use of the filestream feature.
So what I did was connect to the database with SQL Server Management Studio, and then connect to it in VisualStudio.

Related

SQL Server version error while attaching a mdf file

TITLE: Microsoft SQL Server Management Studio
Attach database failed for Server 'DESKTOP-MR6JCUA'. (Microsoft.SqlServer.Smo)
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch.
(Microsoft.SqlServer.ConnectionInfo)
The database 'ABC_Management_System' cannot be opened because it is version 869. This server supports version 852 and earlier. A downgrade path is not supported.
Could not open new database 'ABC_Management_System'. CREATE DATABASE is aborted. (Microsoft SQL Server, Error: 948)
Your Sql server 2016 database that you are importing into cannot load the Sql Server 2017 backup.
One Solution:
The SQL Utilities that create bacpac files with schema and data can accomplish this usually. You would be transferring the data from one sql server to the other. It would be a fancy copy operation that does not rely on the backup file. Pay attention to target and source if you do this.
Another Solution:
Upgrade your “2016” server to a 2017 server, but you should also consider installing a second 2017 Instance next to your 2016 instance if your 2016 target is a really a dev machine. Then you will be able to restore your original 2017 backup file into your new 2017 sql server instance.
Please select Data source as .\sqlexpress intead of (localdb)\MSSQLLocalDB
For example, try to set the Database connection string as
Data Source=.\sqlexpress;AttachDbFilename=C:\\...\\XXX.mdf; Integrated Security=True;

SSIS file started by SQL Server Agent fails (Source SQLISPackage120, Event ID: 12291)

I have SSIS file *.dtx which works on test machine with test sql server and works locally started with production/test sql server. When the file is moved to production machine and started with production machine (no change of credection in SSIS file) it fails with message in event log: Source SQLISPackage120, Event ID: 12291.
The logging is turned on: with works everywhere except production machine. It logs also when SSIS file is started locally from VS but with production database.
How to find more information about problem?
UPDATE1:
I found in SQL Agent log file entry:
Login failed for user 'aaa'. Reason: Password did not match that for the login provided. [CLIENT: ...]
How to configure windows user to be able to run SSIS task (or to be able to log in SQL server from SSIS)?
The real problem was that user defined in SSIS's connection string had no access to production's database called XXX.
The most important information were found in SQL Server log file:
C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Log\errorlog

Use ODC file stored in SharePoint to connect InfoPath to SQL server

I am trying to create an InfoPath 2010 form that does the following:
Uses an ODC file which is stored in a SharePoint 2010 data connection library (for an SQL database)
Connects to SQL Server 2008 (which resides on the same domain)
Queries a table to pull results for use in the form
It works just fine when the ODC file is stored on my C drive, but as soon as the ODC file is uploaded to the connection library and I try to modify it (or create a new ODC file) the following error message appears:
An unspecified error occurred while attempting to connect to the data source. Microsoft InfoPath supports only Microsoft SQL Server and Microsoft Access database. Check the connection to ensure it uses one of those two databases.
If I manually modify the save location of a new ODC file to the SharePoint connection library the following window appears:
But it is promptly followed by the same error message:
I'm certain SharePoint and InfoPath can accommodate this... I am just not certain why it is occurring.
Going to answer my own question. Just convert the connection to a file. In InfoPath 2010 this means Data Tab>Data Connections>Select Desired Connection>Click "Convert To Connection File"
You will then be prompted for a URL to save the file at. Easy as that...

SQL Server 2012 - Cannot create an instance of OLE DB provider "Microsoft.Jet.OLEDB.4.0" (Microsoft SQL Server, Error: 7302)

I just installed SQL Server 2012 to test differences and make sure it is ok for my Work. I may not be a pro at SQL, but I don't see how to add a Link to Jet database on my server. I have imported Jet Databases, but when going thru the GUI to Link a JET Database I see no Provider for JET. I am running Access 2003 (I don't like the 2008+ GUI)
I searched an found nothing simular to my issue; at least nothing I understood. Nothing mentioned how to add Jet db Provider.
I ran a connection string to the Jet Database thru QA:
sp_addlinkedserver 'USGEScrub', 'Access', 'Microsoft.Jet.OLEDB.4.0',
'D:\Lead$\SupList\USGEScrub.mdb'
The connection string works till I try to access the data and then I get this the errorand of course if I click the links nothing shows up:
TITLE: Microsoft SQL Server Management Studio
Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&LinkId=20476
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch.
Cannot create an instance of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked
server "USGEScrub". (Microsoft SQL Server, Error: 7302)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=11.00.2100&EvtSrc=MSSQLServer&EvtID=7302&LinkId=20476
download the 2010 Access database engine from Microsoft
Allow "InProcess"
Add linked server using the ACE OLEDB provider.
more details here
I had a similar problem and in my case it turned out to be related to the permissions on the %TEMP% folder for the account under which the SQL Server service was running. For more details see my answer here.
Sometimes this problems occurs in computers x64 with office x84 versions installed. Try this:
Install pasive OleDb Driver x64

Unable to attach "AdventureWorks2008" Sample Database to a named Instance in SQL Server 2008

First of all "Northwind" and "AdventureWorksDW2008" databases attached without problem, but "AdventureWorks2008" fails with the following error.
//Msg 5120, Level 16, State 105, Line 1
Unable to open the physical file
"C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\Documents".
Operating system error 2: "2(The system cannot find the file specified.)".
Msg 5105, Level 16, State 14, Line 1
A file activation error occurred. The physical file name
'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\Documents'
may be incorrect. Diagnose and correct additional errors, and retry the operation.
Msg 1813, Level 16, State 2, Line 1
Could not open new database 'AdventureWorks2008'. CREATE DATABASE is aborted.
I did not use the default database instance "MSSQLSERVER" during install.
So where is it finding this path "C:...\MSSQL10.MSSQLSERVER...\Documents"?
go to sql server configuration manager
sql server services SQL Server(MSSQLSERVER)
change the "log on as" to "local system"
First of all you need to enable the FILESTREAM usage:
EXEC sp_configure filestream_access_level, 2
RECONFIGURE
After that you can create the DB:
USE [master]
GO
CREATE DATABASE [AdventureWorks2008] ON
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLTRAININGKIT\MSSQL\DATA\AdventureWorks2008_Data.mdf' ),
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLTRAININGKIT\MSSQL\DATA\AdventureWorks2008_Log.ldf' ),
FILEGROUP [PRIMARY] CONTAINS FILESTREAM DEFAULT
( NAME = N'Documents', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLTRAININGKIT\MSSQL\DATA\Documents' )
FOR ATTACH
GO
Change the TRAININGKIT instance name for your instance name and check the paths after that run with sysadmin privileges.
This is my solution for SQL2008R2 :
Create folder Documents under Data folder
Start MSSQL Mgmt Studio (run as Admin)
Set Filestream Access Level to Full Access Enabled (Srv properties/Advanced)
Attach db AdventureWorks2008R2.mdf (add db and remove Log file before attaching)
just like SQL Guy! i enabled FILESTREAM from configuration manager=>services=>yourinstance=>right-click=>properties=>advanced and then i you can
remove the necessity of the log file from the attachement menu ( right click on database in sql => attach...). and it worked!
It was appearing to work, but becoming Suspect after SQL service restart. SQL Log said:
Message FILESTREAM's file system log record 'placeholder.txt' under
log folder '\?\C:\Program Files\Microsoft SQL
Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\Documents\$FSLOG' is corrupted.
Combining various suggestions found above, I got it to work (and survive service-restart without going Suspect) by:
Grant SQL service account FULL permissions to the MDF & LDF files and the Documents folder BEFORE copying them into DATA.
Delete C:\Program Files\Microsoft SQL
Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\Documents\$FSLOG\placeholder.txt
(R2 BOL hints at this, but directs it at the wrong level).
CREATE DATABASE [AdventureWorks2008] ON ( FILENAME =
N'C:\Program Files\Microsoft SQL
Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\AdventureWorks2008_Data.mdf'
), ( FILENAME = N'C:\Program Files\Microsoft SQL
Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\AdventureWorks2008_Log.ldf' )
, FILEGROUP [PRIMARY] CONTAINS FILESTREAM DEFAULT ( NAME =
N'Documents', FILENAME = N'C:\Program Files\Microsoft SQL
Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\Documents' )
FOR ATTACH_REBUILD_LOG
Solved it by below ways:
I fixed it As the .mdf and .ldf files where on different drives,
it was giving some wierd error so i attached only mdf files and the server created .ldf files on the same drive as mdf. this way i could attach it but then i took the db offline copied the log from D:\ to E:\ and then brought the db online. it worked.
and sometimes you can :
try login with Windows Authentication and
Start SQL Server manager as Administrator (right-click on the program, choose "Start as administrator")
Seems like many are having this issues, including me, and including the guy who logged this bug with MS Connect:
http://connect.microsoft.com/SQLServer/feedback/details/567193/adventureworks-2008-fails-to-attach
This is the only way I could get it to work. (Install without filestream)
Go to Download 'AdventureWorks 2008R2 OLTP Script'
Unzip and open the instawdb.sql script. Remember to set the variables at the top of the script. Run the script. This should bulk load all the data as well. Good luck!
This worked for me:
Software used-SQL Server 2008 Express R2, Windows Vista OS, Adventureworks2008R2.mdf
Place the database in the Program files(X86)\Microsoft SQL
Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA folder (or similar location
for your operating system)
All my installation files are in the default. This was done on
Windows Vista with SQL SERVER Express 2008R2. The database used was
Adventureworks2008R2.mdf.
IMPORTANT PART---After picking the database in SSMS ATTACH DIALOGUE
BOX you must Remove the log file first (within the Attach dialogue
box), (.ldf file). If you do not Remove this file the attachment
will fail with an error message.
Database attached and is working perfectly without any changes to
accounts or logins or any other steps.
In my case the problem had to do with the file I was using and the version of SQL. I have installed SQLServer2008R2 and the file I was using was AdventureWorks2008_Data.mdf. I downloaded the one from here http://msftdbprodsamples.codeplex.com/releases/view/59211 (AdventureWorks2008R2_Data.mdf) and all is fine now.