Am trying to learn MDX using book called "Microsoft SQL Server 2008 MDX Step by step", and i downloaded the samples databases for the book , but when trying to attach the database it gives me an error "Access denied" , I'm trying to attach the database to SQL Server 2008 R2,
will it make a difference to attach it to R2 as the book tutorial and samples is for 2008 only ??,
Note that i searched for the error and it said that i had to delete also the log file that is downloaded with the samples database, i did that also but nothing worked
Please help
I had the same error several times. It has nothing to do with your version, i have done it on both SQL Server 2008 and SQL Server 2012. It´s because of some denied access to the folders where you downloaded and installed the MDX-stuff. One way to solve it is to copy the "MdxStepByStep.mdf" & "MdxStepBySteplog" files to your data-folder where the other databases lies. My path is for example:
"C:\Program Files\Microsoft SQL Server\MSSQL11\MSSQL\DATA".
Then you just change the script´s path to:
exec master..sp_attach_db
'MdxStepByStep',
'C:\Program Files\Microsoft SQL Server\MSSQL11\MSSQL\DATA\MdxStepByStep.mdf'
Do not copy the "MdxStepByStep_log" because then you will get an error that the file already exists.
It should work, also there should not be any problem with the analysis cube if i remember correctly, tell me if there is and i will look into it.
Related
I've been dealing for trying to migrate a really big database to an earlier SQL Server with multiple ways, I started doing a .bak file, but I found that it is not compatible and it should be the same SQL Server version.
Then I chose the task - generate Script, to create a .sql file with all schema and data, but the file was 24gb big! Even though the file was really big by using the sqlcmd I managed to execute it. But it never finished executing successfully, it threw multiple types of errors, like:
Msg 156, Level 15, State 1:
Incorrect syntax near the keyword '...'
Msg 105, Level 15, State 1
Unclosed quotation mark after the character string
Then I found this comment with 2 solutions https://stackoverflow.com/a/27623706/3192041, I tried the first one but still throwing the second error, I tried the second one and It worked! everything was now running smoothly, but then I got another error...
This error:
Sqlcmd: Error: Internal error at ReadText (Reason: An attempt was made
to move the file pointer before the beginning of the file).
So now the issue has something to do with sqlcmd command??
Should I continue trying to migrate the database with the generated script? is there a better way of this and making it compatible with an earlier SQL Server version?
Things to clarify
I first created a script only with schema information, but when I tried to generate a separate script for data only the SSMS was throwing an error. So with this way I can't or I don't know how to export all data with an easy way. I know you could export data for each of the tables, but the database has more than 200 tables and this is not viable.
Also the script takes more than one hour, and maybe a lot more than that time if the process would finish correctly.
Finally after also trying with a bacpac file, that also didn't let me to create because of a bunch of errors of windows users, external object references, and more...
The best answer to solve this, is by creating a .dacpac file. The dacpac file from SSMS 2012 to the latest versions, you can now include the data of all your tables.
And to solve the incompatibility issue, you can use the AllowIncompatiblePlatform property to allow deployment to different versions of SQL Server when publishing to the target server.
so first you need to extract using the SqlPackage.exe from your bin folder of the sql server, in my case this is the folder: C:\Program Files (x86)\Microsoft SQL Server\130\DAC\bin
then run the command with the Extract action:
SqlPackage /Action:Extract /SourceDatabaseName:"<database-name>" /SourceServerName:"<server-name>" /SourceUser:"sa" /SourcePassword:"<password>" /TargetFile:"<dacpac-file-path>" /p:ExtractAllTableData=True
Then in the other server run this command in correct bin folder of the SqlPackage.exe program:
SqlPackage /Action:Publish /SourceFile:" <dacpac file path>\filename.dacpac" /TargetDatabaseName:"<database name>" /TargetServerName:"<ServerName>" /TargetUser:"<username>" /TargetPassword:"<password>(if needed)" /p:AllowIncompatiblePlatform=true /p:CreateNewDatabase=true
And If you want to create the database from scrath.
/p:CreateNewDatabase=true
I hope this helps anyone with this problem, with big databases, and importing from a bigger sql server version.
Not getting "IF Not EXIST" option is not getting in sql server while generating script file. This option was present in sql server 2008 but not showing in 2012
While generating script file in SQL Server 2012 we can’t see the “IF NOT EXIST’ option , which was present in SQL Server 2008 to check the existence of the object. This feature is also present in 2012 but we have make true the option “Check for object existence” to get the same output as SQL Server 2008.
How can I import a .dbf file into SQL Server using a SQL script?
Found answers from this post, but unfortunately none of them work to me :( :
Trying to Import FoxPro DBF File to SQL Server
and
How to import a DBF file in SQL Server
When I'm trying this code :
SELECT *
INTO [APP_DB]..[BILLHEAD]
FROM OPENROWSET('MSDASQL', 'Driver=Microsoft Visual FoxPro Driver; SourceDB=D:\DBF; SourceType=DBF', 'SELECT * FROM BILLHEAD')
I get this error:
OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified". Msg 7303, Level 16, State 1, Line 1 Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "(null)".
And also, when trying this :
SELECT *
FROM openrowset('VFPOLEDB','D:\DBF\BILLHEAD.dbf';'';
'','SELECT * FROM BILLHEAD')
I get this error :
Msg 7438, Level 16, State 1, Line 1
The 32-bit OLE DB provider "VFPOLEDB" cannot be loaded in-process on a 64-bit SQL Server.
I don't want to download any third party application. That's why I'm trying all the possible solution and I need your help now guys. I'm creating a small application to import .DBF files into SQL Server.
Regards,
You are using 64-bit SQL sever, but FoxPro OLE DB driver is 32-bit. You need to consult this article which discusses how to use the 32-bit OLE DB driver with 64-bit SQL Server.
Gimo, I'm not sure this will work and I'm no MS SQL Server expert, but I've been wrestling with a similar problem lately and I have an idea. I think you may be able to get that first block of code from your question to work if you execute the following statements first:
EXEC sp_configure 'show advanced options', 1
RECONFIGURE;
GO
EXEC sp_configure 'Ad Hoc Distributed Queries', 1
RECONFIGURE;
GO
This may not work if you don't have adequate permissions (which happened in my situation), but it may be worth a shot.
Our office SQL/GIS guru, Burce, solved a similar problem I was having. I'm not sure of all the details of how he did it, so while I am reluctant to enter this as an "Answer" (it is too many characters to enter as a Comment) I'll describe what I can in case it is helpful for anyone. First be aware that he has full permissions on the SQL Server, so this solution may not be feasible for all DB users to implement. Bruce set up a Linked Server that's connected to a directory ".../DBF/" on our LAN file server. He also set up a similar Linked Server & directory for CSV files. Anyone in our office can simply copy a DBF file to this directory and then access it in SQL Server as if it were a regular table in a SQL Server database. I access this in SSMS by connecting to the Database Engine then going to Server Objects > Linked Servers > "DBF" > Catalogs > default > Tables > file name . The Properties of the Linked Server say the following:
From General tab of Properties window
From Security tab of Properties window
From Server Options tab of Properties window
Note that this may or may not be a secure configuration for all database server environments, but this is on a SQL Server that is on our internal network, only accessible within our office, with no endpoints or access outside our LAN (it's not used as a server for web, or other internet services).
I have had similar problems where stuff just wasn't working trying to move legacy tables from VFP to SQL 2008R2 and used the following procedure:
select table within VFP
copy to blahblah xl5
Step 2 results in an excel file
Use SQL 2008 R2 or higher "Import and Export Data (32 bit)" to import the excel file.
I was running Windows 7 64 bit and still had to use the 32 bit import to make it work smoothly.
This may explain why you need the 32 bit Import: https://msdn.microsoft.com/en-us/library/ms141209.aspx
Having real problems creating a DB on my version of SQL Server 2008 R2 Express.
I've followed the links to the below but no info provided.
Thanks in advance for any help.
TITLE: Microsoft SQL Server Management Studio
Create failed for Database 'test'.
(Microsoft.SqlServer.Smo)
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1600.1+((KJ_RTM).100402-1539+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+Database&LinkId=20476
ADDITIONAL INFORMATION:
An exception occurred while executing
a Transact-SQL statement or batch.
(Microsoft.SqlServer.ConnectionInfo)
Directory lookup for the file
"D:\DATA\test.mdf" failed with the
operating system error 2 (failed to
retrieve text for this error. Reason:
15100). CREATE DATABASE failed. Some
file names listed could not be
created. Check related errors.
(Microsoft SQL Server, Error: 5133)
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1600&EvtSrc=MSSQLServer&EvtID=5133&LinkId=20476
I would assume the issue has to do with the creation of the mdf file in your D:\Data folder. Can you verify that you have the permissions you need to that location and that you have enough free space? Also, be sure there isn't already an mdf file by that name at that location.
open the DB properties and on the files page (on the right panel) make sure that you dont have database files with duplicate names. if there are change their names
When trying to connect to a server in Management Studio (specifically 2008), there is a field where you enter the Server name. That field also has a drop-down list where it shows a history of servers that you have attempted to connect to.
How to remove an individual item
from that history?
How to remove an
item from the Login field history
for each Server name?
As of SQL Server 2012 you no longer have to go through the hassle of deleting the bin file (which causes other side effects). You should be able to press the delete key within the MRU list of the Server Name dropdown in the Connect to Server dialog. This is documented in this Connect item and this blog post.
Note that if you have multiple entries for a single server name (e.g. one with Windows and one with SQL Auth), you won't be able to tell which one you're deleting.
Here is simpliest way to clear items from this list.
Open the Microsoft SQL Server Management Studio (SSMS) version you want to affect.
Open the Connect to Server dialog (File->Connect Object Explorer, Object Explorer-> Connect-> Database Engine, etc).
Click on the Server Name field drop down list’s down arrow.
Hover over the items you want to remove.
Press the delete (DEL) key on your keyboard.
there we go.
For SQL 2005, delete the file:
C:\Documents and Settings\<USER>\Application Data\Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.dat
For SQL 2008, the file location, format and name changed:
C:\Documents and Settings\<USER>\Application Data\Microsoft\Microsoft SQL Server\100\Tools\Shell\SqlStudio.bin
How to clear the list:
Shut down all instances of SSMS
Delete/Rename the file
Open SSMS
This request is registered on Microsoft Connect
Over on this duplicate question #arcticdev posted some code that will get rid of individual entries (as opposed to all entries being delete the bin file).
I have wrapped it in a very ugly UI and put it here: http://ssmsmru.codeplex.com/
For SQL Server 2012 Management Studio, this file has moved. It is now located at:
C:\Users\<username>\AppData\Roaming\Microsoft\
SQL Server Management Studio\11.0\SqlStudio.bin
In Windows Server 2008 standard with SQL Express 2008, the "SqlStudio.bin" file lives here:
%UserProfile%\Microsoft\Microsoft SQL Server\100\Tools\Shell\
Here is an easy way.
Open the connection window, click on the Server name dropdown, and hover over the connection string you want to delete, then press delete.
Delete the file from above path: (Before delete please close SSMS)
File location path for the users of SQL Server 2005,
C:\Documents and Settings\%USERNAME%\Application Data\Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.dat
File location path for the users of SQL Server 2008,
Note: Format Name has been changed.
C:\Documents and Settings\%USERNAME%\Application Data\Microsoft\Microsoft SQL Server\100\Tools\Shell\SqlStudio.bin
File location path for the users of Server 2008 standard/SQL Express 2008
C:\Documents and Settings\%USERNAME%\Microsoft\Microsoft SQL Server\100\Tools\Shell\SqlStudio.bin
File location path for the users of SQL Server 2012,
C:\Users\%USERNAME%\AppData\Roaming\Microsoft\SQL Server Management Studio\11.0\SqlStudio.bin
File location path for the users of SQL Server 2014,
C:\Users\%USERNAME%\AppData\Roaming\Microsoft\SQL Server Management Studio\12.0\SqlStudio.bin
Note: In SSMS 2012 (Version 10.50.1600.1 OR Above), ow you can remove the server name by selecting it from dropdown and press DELETE.
In SSMS 2012 there is a documented way to delete the server name from the "Connect to Server" dialog. Now, we can remove the server name by selecting it in the dialog and pressing DELETE.
File SqlStudio.bin actually contains binary serialized data of type "Microsoft.SqlServer.Management.UserSettings.SqlStudio".
Using BinaryFormatter class you can write simple .NET application in order to edit file content.
From the Command Prompt (Start \ All Programs \ Accessories \ Command Prompt):
DEL /S SqlStudio.bin
This is the correct way of doing it
http://blogs.msdn.com/b/managingsql/archive/2011/07/13/deleting-old-server-names-from-quot-connect-to-server-quot-dialog-in-ssms.aspx
For Windows Vista and SQL Server 2005,
Delete this file, or open it with the Notepad and clear the server names that you want Clear from the history
%UserProfile%\Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.dat
C:\Users\\AppData\Roaming\Microsoft\Microsoft SQL Server\100\Tools\Shell
Rather than deleting or renaming this file:
Close SQL Server Management Studio.
Find the appropriate file (see the other posts).
Open the .bin in a text/hex editior like NotePad++.
Search for the name of one of the servers and identify the line number.
Make a copy of the .bin/.dat file.
Delete that line. Make sure you delete the entire line, it's possible if you have many the line could wrap.
Open SQL Server Management Studio. Your dropdown will be blank.