adding owner into SQL Server 2005 database - sql-server

SharePoint on SBS Server 2008 has been playing up lately and just gives a 404 message. I think I have found what is wrong with it. The database seems to have no owner![No database owners][1]
I am trying to resolve this at the moment using
USE SampleDB
EXEC sp_changedbowner 'DOMAINNAME\USERNAME'
command. This gives me an error:
Msg 911, Level 16, State 1, Line 1 Could not locate entry in
sysdatabases for database 'SharePoint_AdminContent_d4e397f2'. No entry
found with that name. Make sure that the name is entered correctly.
Does anyone know how to apply an owner to the database?

I suspect that the problem is with the USE SampleDB command. The error indicates that it can't find your SharePoint_AdminContent_d4e397f2 database. Check the spelling of your database in the USE command.

Related

Error while execute db to server

Have tried for hours to execute my db to my server, but keeps getting the same error.
What I did first what on my local dbd i did go to tasks -> generate scripts where I under scripts options chose schema and data. After the script was generated, I logged in to my hosts server, where i dragged the database in to my SQL Server Management Studio. Then I removed all the following text:
Gist with text
and replaced the USE [aspnet-Billigcsgosalgssite-20170731103725] with
USE sql6003.smarterasp.net
After that I did the execute, and got the following error code:
Msg 911, Level 16, State 1, Line 1
Database 'sql6003' does not exist. Make sure that the name is entered correctly.
Msg 102, Level 15, State 1, Line 223
Incorrect syntax near '.'.
I really don't know what to do anymore, and would be happy for some help!
I think first you need to create database on your local machine
create database sql6003
After this run the script that you have taken from different server

Unable to attach database in Amazon RDS SQL Server

I'm trying to detach and attach a database in AWS RDS. I'm able to detach the database without any issues. But while I try to attach the database, I'm getting few errors.
When I run the attach command for the first time, I get the following error:
Unable to create database: User, group, or role 'sa' already exists in the current database.
When I execute for the second time, I get this:
Msg 1802, Level 16, State 7.
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
Msg 5120, Level 16, State 101.
Unable to open the physical file "D:\RDSDBDATA\DATA\DBattachTest.mdf". Operating system error 2: "2(The system cannot find the file specified.)". (Line 6)
Please advise
I'm not sure what you are trying to do but you should be using backup and restore functionality to move DBs around. Attach and detach will not work as they do in a traditional SQL environment: RDS is a managed service and you have extremely limited access to the underlying OS.
From AWS docs:
Restoring a Database
To restore your database, you call the rds_restore_database stored procedure.
The following parameters are required:
#restore_db_name – The name of the database to restore.
#s3_arn_to_restore_from – The Amazon S3 bucket that contains the backup file, and the name of the file.
The following parameters are optional:
#kms_master_key_arn – If you encrypted the backup file, the key to use to decrypt the file.
Example Without Encryption
exec msdb.dbo.rds_restore_database
#restore_db_name='database_name',
#s3_arn_to_restore_from='arn:aws:s3:::bucket_name/file_name_and_extension';
Example With Encryption
exec msdb.dbo.rds_restore_database
#restore_db_name='database_name',
#s3_arn_to_restore_from='arn:aws:s3:::bucket_name/file_name_and_extension',
#kms_master_key_arn='arn:aws:kms:region:account-id:key/key-id';

Getting script errors when generating SQL script for Azure using SQL Server Management Studio

I am using the free azure websites and made an sql database. I need to create the db tables, and then insert the dummy in.
I tried to generate the scripts through sql management studio but I get a lot of errors when I run it against the azure db.
Msg 40508, Level 16, State 1, Line 1
USE statement is not supported to switch between databases. Use a new connection to connect to a different Database.
Msg 102, Level 15, State 1, Line 5
Incorrect syntax near 'CONTAINMENT'.
Msg 102, Level 15, State 1, Line 11
Incorrect syntax near 'COMPATIBILITY_LEVEL'.
How can I get the data into my azure database?
Just taking a guess here, based on the errors: When generating scripts via SSMS, you need to specify output specific to Windows Azure SQL Database (formerly known as SQL Azure). I don't have it installed at the moment so I can't provide you with a screenshot. I'll update my answer, should I get it installed before you verify this is indeed the issue.
as David mentioned above, you can specify the script generation to target Windows Azure SQL Database
Hi this may be a little late but I found the this link to be helpful:
You basically have to manualy change the context (click on the correct database on the list of dropdown) before executing the query. You may have noticed this when working between databases.
Hope this helps

MSSQL mirroring error 1499

I`ve got a problem with my mirroring. I have already uses this feature to make 2 db work.
But it was on test bases.
Now when I use my scripts on work DB it throws an error:
Msg 1499, Level 16, State 1, Line 1
Database mirroring error: status 1488, severity 16, state 1, string db_name.
Any suggestions?
you database may be in single user mode
right click the database -> options and select MULTI USER under restrict access
try to check the principal and mirror server names, dtabase name etc. It is possible that there is misprints.
This happened to us recently. We found that SQL set the restored database to single user mode during the restore process.
After some research, we simply restarted SQL server services on the mirror. When SQL started back up, the restored database was in multi-user mode and we were able to initialize mirroring without any issues.
There are other sites out there with answers as well, but they involve taking down the principle database. That was not really an option for us at the time. Here is one example in case restarting the mirror does not help the next person who runs into this.
http://blog.armgasys.com/?p=259
I had some what similar issue this is how I solved it. When I ran wizard for mirroring it created endpoints(first part) successfully but when i tried to turn on mirroring it gave me error.
So I solved it by running below command on both server
USE [master]
alter database [yourdatabase] set partner off;
go
--Secondary already had partner but primary did not
--- then i ran below commands on each server.
USE [master]
ALTER DATABASE [yourdatabase]
SET PARTNER = 'TCP://OtherMachineSQLname.domain.LOCAL:5022';
GO
-- then mirroring started to work.

How can I fix "SQL03042: The ALL clause is not supported"?

I have just recently added our db schema into a VSTSDB project and one of the sp's is coming up with a strange error on the line:
revoke all from StatsReports
Now I've taken a look at the Sql docs for the "revoke" command and according to that it is valid sql. Also searching for the error number or text brings up nothing!
Anyone have any ideas?
It is valid TSQL, but the error message is - I assume - coming from VSTSDB, not from SQL Server. Running your query directly against a SQL 2008 database gives the following message:
The ALL permission is deprecated and maintained only for compatibility. It DOES NOT imply ALL permissions defined on the entity.
My guess is that VSTSDB shows an error on this syntax in order to 'remind' you to update your code. The deprecation is documented under the main page for the REVOKE command.

Resources