vsdbcmd data loss may occur, but where? - database-project

When using vsdbcmd to deploy my database:
vsdbcmd.exe /a:Deploy /manifest:MyDatabase.deploymanifest
I Get:
SQL01268 .Net SqlClient Data Provider: Msg 50000, Level 16, State 127, Line 6 Rows were detected. The schema update is terminating because data loss might occur.
SQL01268 An error occurred while the batch was being executed.
Which is fine, but it doesn't tell me where the dataloss will happen. In order to find out I have to use <DeployToScript>True</DeployToScript>, then load the script up to see:
IF EXISTS (select top 1 1 from [dbo].[MyTable])
RAISERROR ('Rows were detected. The schema update is terminating because data loss might occur.', 16, 127) WITH NOWAIT
Is there a way to get vsdbcmd to display this info when deploying direct to the DB without having to generate the sql first?
Thanks

There is no way to do this, it's a bug (or missing feature). See Tom's comment to my question.

For me I was needed to empty my DB before deploying SQL

Related

Error 8921 running DBCC CHECKDB

DBCC CHECKDB shows following error message in my sql server 2008 R2 database
Msg 8921, Level 16, State 1, Line 2
Check terminated. A failure was detected while collecting facts. Possibly tempdb out of space or a system table is inconsistent. Check previous errors.
What is the solution?
Given that DBCC CHECKALLOC fails too, with no corruption messages, your database has corrupt metadata and you need to restore from your backups (the first thing it does is run some basic checks on the three critical system tables it needs, and if they're badly broken, it will fail with message 8921). You have no other choice here - you can't run repair as you can't get DBCC CHECKDB to run.
It's possible you could narrow down which system table is corrupt using DBCC CHECKTABLE on successive object IDs from sys.objects, and then manually edit around the corruption, but that's very advanced and has a very low chance of success.
If you don't have any backups, you're going to have to create a new database and then export all the schemas and data into the new database.

Database Recovery Model alter script error

I am trying to deploy one of our server via teamcity (db project in VS 2012), i am getting an error on Staging server
Error SQL72014: .Net SqlClient Data Provider:
Msg 5069, Level 16, State 1, Line 5
ALTER DATABASE statement failed.
Error SQL72045: Script execution error.
The executed script:
IF EXISTS (SELECT 1
FROM [master].[dbo].[sysdatabases]
WHERE [name] = N'$(DatabaseName)')
BEGIN
ALTER DATABASE [$(DatabaseName)]
SET RECOVERY SIMPLE
WITH ROLLBACK IMMEDIATE;
END
Any ideas are appreciated.
Don't just gloss over the problem: understand it.
It's because you have some sort of HA (you said mirroring in the comment above, but availability groups (for sure) or log shipping (I think) would also cause this) that requires that the database be in full recovery. When you try to set it to simple recovery, it fails because you can't set the recovery model to anything but full for such a database. You could guard against this by checking what environment you're deploying to from VS and act accordingly.

Error while enabling CDC on table level

I am enabling Change data capture (CDC) on SQL server 2012 Enterprise edition(11.0.2100.60)
. I am able to enable it on Database level with below SQL, but failed to enable on Table level.
Use DatabaseName
GO
Exec sys.sp_cdc_enable_db
GO
EXEC sys.sp_cdc_enable_table #source_schema = N'dbo'
,#source_name = N'TableName'
, #role_name = NULL
GO
Got Error like,
'msg 22832, Level 16, State 1, Procedure sp_cdc_enable_table_internal,
Line 623
Could not update the metadata that indicates table [dbo].[TableName]
is enabled for Change Data Capture. The failure occurred when
executing the command '[sys].[sp_cdc_add_job] #job_type = N'capture''.
The error returned was 22836: 'Could not update the metadata for
database DatabaseName to indicate that a Change Data Capture job has
been added. The failure occurred when executing the command
'sp_add_jobstep_internal'. The error returned was 14234: 'The
specified '#server' is invalid (valid values are returned by
sp_helpserver).'. Use the action and error to determine the cause of
the failure and resubmit the request.'. Use the action and error to
determine the cause of the failure and resubmit the request.'
Would anyone help me to out of this?
Thanks in advance..!!
I had the same problem recently.
In my opinion, it is highly probable that the name of the computer has changed.
If it is true, read on ...
Name Changing the computer is automatically recognized by SQL. However, system metadata must be updated manually.
(Source: http://msdn.microsoft.com/en-us/library/ms143799.aspx)
SQL Statement
sp_dropserver old_name\instancename;
GO
sp_addserver new_name\instancename, local;
GO
Example
sp_dropserver name-PC\SQLEXPRESS;
GO
sp_addserver CLT55\SQLEXPRESS, local;
GO
Reference problem and solution

SQL Server error "Could not continue scan with NOLOCK due to data movement."

I am having an issue when running queries or stored procedures. Every time I run a query I get the following error:
Could not continue scan with NOLOCK due to data movement.
If I remove the WITH NOLOCK command, I get a different error:
Msg 824, Level 24, State 2, Line 1
SQL Server detected a logical consistency-based I/O error: incorrect pageid (expected 1:19818941; actual 1:19818957). It occurred during a read of page (1:19818941) in database ID 9 at offset 0x000025cd37a000 in file 'E:\SQLDATA\MSCRM.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.
What should I do to resolve this error?
First, obviously, try DBCC CHECKDB.
If that cannot resolve the issue, you may need to restore from a backup and then manually copy over the most recent changes. Hopefully you have been doing nightly backups... ?
If the error is prefixed with any object (Proc, trigger, function), then you can just drop and create the object again or alter it if possible.

uncommittable transaction is detected at the end of batch. the transaction is rolled back

We are having problem with the server migration. We have one application that are having
so much transactions It working fine on the one database server. But when transfer same database to another server. We are facing the following error.
Server: Msg 3998, Level 16, State 1, Line 1
Uncommittable transaction is
detected at the end of the batch. The
transaction is rolled back.
Same database is copied to the another server with the all data. If we change connectionstring to old server then it is working fine.
Can anybody suggest on this?
This message means one of the other participants in the transaction voted to rollback. After that the transaction must fail.
So this message is a consequence, rather than a cause. Are you receiving any earlier / other error messages?
What happens when you run the query from Management Studio?
What you seem to have is a problem where the record is acceptable in one database but not theother. Suggest you look at the differnces between the two database structures (yes I know they are supposed to be the same, but clearly they are not). Suspect you will either find a collation difference, a data type differnce, or a data length differnce between the two. YOu might also have a table where the identity definition is missing and thus it can't insert becasue it is a required field and the value is missing. Tools like SQl Compare are easy to use to find differences.