SQL Server 2008 R2, cant create a new DB - sql

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

Related

SSIS Error: Invalid object name - but object exists and query runs in SSMS

I'm currently updating all of our ETLs using Visual Studio 2015 (made in BIDS 2008) and redeploying them to a new reporting server running on SQL Server 2016 (originally 2008R2).
While updating one of the ETLs I got this error:
Exception from HRESULT: 0xC0202009 Error at Load Staging Table [OLE DB
Source [129]]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has
occurred. Error code: 0x80004005. An OLE DB record is available.
Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80004005
Description: "Invalid object name 'dbo.TimeSheets'.".
Here's what I've tried:
Checked my connection strings to make sure they were correct.
Checked the schema to make sure it existed and was correct.
Ran query from SSMS and it worked.
Ctrl + Shift + R to refresh intellisense.
Checked to see if another table exists with the same name.
Restarted Visual Studio and SSMS.
I got a successful fix from the comments of the question "The other option would be to fully qualify the table name {database}.{schema}.{table} to ensure that, regardless of the default catalog, you query the correct database."
I was using some other database and it was caching and using that DB name rather than the new one I changed to.
I encountered the same issue - my Database was somehow, not getting picked up. So I manually added the database and test the connection and now it works fine.
For SSIS - Specially it is observed if any table name is coming as "Invalid object name" then Check as -
First - Check table exist through SSMS and if not then SSMS> Edit > IntelliSense > Refresh Local Cache
Second - While making DB connection via "Connection manager" or already exist then - check table name comes in drop down of "Name of the table or View"
I tried several of the above suggestions but what worked for me in the end was the good old close and re-open of SSDT!
I just had the same issue.
Both SSIS and SSMS refused to find the table [Stage].[Customer], although it definetly existed (and had existed for quite some time).
Dropping and re-creating the table did no good. Also I noticed that SSMS's intellisense did not pick up that the table had been re-created (yes, after ctrl+shift+R)
What helped in the end was using
CREATE TABLE [Stage].[Customer] ([Id] INT)
in SSMS
This caused an error because the table already existed. Since then both SSMS and SSIS are working as expected. No idea what caused this error, but it is been difficult to track down.
Same issue.
I could see the corresponding tables in the drop-down in several of my OLE DB Destinations, but it would not let me see the mappings, giving the following error:
"Exception from HRESULT: 0xC0202040... SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005."
What did not work:
Restarted Visual Studio
Several solution cleans/rebuilds
Restarted the computer
What did work:
Closed Visual Studio
Cleared files in %temp% folder
Details
When clearing my %temp% files (those that would delete), one folder (VsHub) would not delete, but I was able to delete some of the files that it contained. When I started Visual Studio again and opened the sequence that contained those OLE DB Destinations, it was obvious that it was re-evaluating the XML code and the error went away.
Hope this helps someone.

MDF File not Opening in SQL Server

My database file of SQL Server 2012 cannot be opened, it causes the following error.
Msg 824, Level 24, State 2, Line 1
SQL Server detected a logical consistency-based I/O error: incorrect pageid (expected 1:903; actual 0:0). It occurred during a read of page (1:903) in database ID 6 at offset 0x0000000070e000 in file 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\inventoryDB.mdf'. Additional messages in the SQL Server error log or system event log may provide more detail. This is a severe error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online.
I also checked it by using
DBCC CHECKDB(inventoryDB, REPAIR_ALLOW_DATA_LOSS)
But the result is given below
DBCC results for 'inventoryDB'.
CHECKDB found 0 allocation errors and 0 consistency errors in database 'inventoryDB'.
Is any possibilities to recover my data from that database file? I am also done many methods in many of the sites. But it not working and shows same error messages.
Do you have any mdf backup after this error occurred? If yes, you should try to create a table and restore from it using your backup.
Or try reading this article:
https://support.microsoft.com/en-ph/kb/2152734
See if it helps with your error.
You've got corruption in your DB. Either the DB was corrupt before you tried working it and you didn't notice, or it was damaged in the work.
Here. We have few options.
Solution one - If you have a backup file, You can restore your database.
Solution two - If you do not have a backup file, you can use DBCC CHECKDB to repair it. (Resource : https://www.stellarinfo.com/blog/how-to-repair-sql-database-using-dbcc-checkdb-command/)
Thanks :)

Error while disabling publishing and distribution

Hi I delete all publications and subscriptions on sql server 2008 . Then try to disabling publishing and distribution for reconfigure replication but have an error :
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
Invalid object name 'dbo.sysmergesubscriptions'.
Changed database context to 'master'. (Microsoft SQL Server, Error: 208) Ho solve it ?
One thing you can do is: create that object by yourself. Most likely there would be more than one table/view missing. Just script those missing objects from another database (for example, develop environment) and create them in your production box.

Problem creating database using SQL Server Management Express

I am trying to create a database using SQL Server Management Express.
The following error occurs:
TITLE: Microsoft SQL Server Management
Studio Express
Create failed for Database
'dbTestDBase'.
(Microsoft.SqlServer.Express.Smo)
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.2047.00&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.Express.ConnectionInfo)
CREATE DATABASE permission denied in
database 'master'. (Microsoft SQL
Server, Error: 262)
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.1399&EvtSrc=MSSQLServer&EvtID=262&LinkId=20476
Run Microsft SQL Server Studio as administrator....your problem will be solved
It's very clear: the credential you are using doesn't have enough privileges to be able to create a new database. Are you logged in using Integrated Windows Authentication or Sql Server Authentication? Make sure your credentials have the dbcreator role either way.
http://msdn.microsoft.com/en-us/library/ms176014%28v=SQL.90%29.aspx
If the computer is part of Domain. Log-in as local administrator account on the work station (maybe because the MSQSQL is installed on the computer using local administrator account, means that the local administrator account has systemadmin access on SMSQL), then when you are already logged as local administrator. open the MSSQL , now add/edit MSSQL security account.
I had this same problem. but solved!
you should go to your specify folder where database created (ex:C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA)
then right click on data folder -> properties-> advanced
then uncheck compress content to save disk space.
that's it.
Well, the error message seems to be pretty clear:
CREATE DATABASE permission denied in
database 'master'.
Obviously, the user account you're using doesn't have the permission to create a new database. Is that possible? What kind of user are you using?
Also: can you show us the CREATE DATABASE statement you're using??
Just check whether path is specified or not
For example : "C:..\MSSQL\DATA", in both the columns of Database files in the New Database wizard
I hope this solution will help someone!
My problem started when I had deleted the previous user from PC Management and from registry. Then I create a fresh-std user. and trying to create database from the new user, and that's where my problem started.
After searching for the better solution, I conclude by Uninstalling MS Server Express Database completely from my PC and re-install it again. This save time and solved my problem.
I hope this solution helps someone too!
I had similar issue and was solved by executing below command
--Step1 Find if it is used by some other PID
Use
master
GO
IF
EXISTS(SELECT request_session_id FROM
sys.dm_tran_locks
WHERE resource_database_id =
DB_ID('Model'))
PRINT
'Model Database being used by some other session'
ELSE
PRINT
'Model Database not used by other session'
-- Step 2 - Identify
SELECT request_session_id FROM
sys.dm_tran_locks
-- Step 3 Get PID
WHERE resource_database_id =
DB_ID('Model')
-- Step 4 Get the EventInfo
DBCC InputBuffer(214)
-- Step 5 Kill the PID
Kill 214
Hope this helps
I had the same problem when trying to create the database with Right Click + New Database on Databases.
The solve was using New Query and the command to create database:
CREATE DATABASE databasename;
In the end I want to mention that I was logged in Management Studio with (localdb)\v11.0 over windows authentication.

Problem restoring a 2005 SQL DB with 2008

I have a DB I created with SQL Server 2005 and created a backup (*.bak) now I want to restore it with 2008 but ouch, I get the following error:
TITLE: Microsoft SQL Server Management Studio
------------------------------
Restore failed for Server 'SHIMMY-PC\SQLEXPRESS'. (Microsoft.SqlServer.SmoExtended)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.0.1600.22+((SQL_PreRelease).080709-1414+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Restore+Server&LinkId=20476
------------------------------
ADDITIONAL INFORMATION:
System.Data.SqlClient.SqlError: The media set has 2 media families but only 1 are provided. All members must be provided. (Microsoft.SqlServer.Smo)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.0.1600.22+((SQL_PreRelease).080709-1414+)&LinkId=20476
------------------------------
BUTTONS:
OK
------------------------------
When you did the original backup, the 'Destination' window had two different paths listed. You selected one, assuming that the backup would use only that one path. What actually happened was that the backup striped itself onto both paths - half the backup onto each. The restore message you are getting is because the restore wants both halves of the backup, but can only find one.
I don't think it's a 2008 problem, can you install the backup back to sql 2005.
Check out this post.