With SSDT in VS 2017 I cannot do a schema comparison of two databases. Steps to reproduce:
Tools >> SQL Server >> New Schema Comparison
Select a source (a SQL 2017 database)
Select a target (a SQL 2017 database)
Compare
Get error: Value cannot be null.
Parameter name: identifierGroup
I've also tried in VS 2015 which was still installed and it failed there too.
This error starts after the identity Cache is disabled
ALTER DATABASE SCOPED CONFIGURATION SET IDENTITY_CACHE = OFF
After re-enabling it, the error disappears:
ALTER DATABASE SCOPED CONFIGURATION SET IDENTITY_CACHE = ON
Don't forget to restart sql service.
I had the same issue and not yet found a solution, I suppose there are some relation with orphan users.
I did a workaround that worked fine to me.
Create a new empty database
Compare the origin database with this new one.
Update the new database with de resulting script.
Make this new database the new origin and compare with the destination database.
Update de destination database.
Maybe this can helps!
I found a different answer which worked for me several times so far using SSDT / Visual Studio 2019 against SQL server 2019 databases.
https://hendrikbulens.com/2018/10/03/how-to-fix-sql-server-data-tools-error-unexpected-exception-caught-during-population-of-source-model-in-visual-studio-2017/
Hope this helps someone. Ideally Microsoft needs to patch this issue, which looks like a longstanding bug at this point. I looked for such a patch but did not find one. If anyone finds one, please do link it here.
Related
While comparing Database instance to a Database project in VS2010 using SSDT, it shows a difference in one of the Stored Procedures. The Store Procedure DDL script is exactly the same but when I expanded the Properties folder under the Store Procedure it show a difference in the DefaultExpressionScript.
The source SP shows this in the DefaultExpresionScript:
DefaultExpressionScript = at
While the destination SP has this:
DefaultExpressionScript = -1
I don't see where I can change this there is no such object called DefaultExpressionScript in my database project. where should I fix this?
This bug is still present in VS 2015 Update 3 with SSDT 14.0.61021.0. However, just scripting the stored procedure with ALTER ... in SSMS and running that query (which shouldn't change anything) fixed it for me. The schema comparison didn't show differences anymore afterwards.
The DefaultExpressionScript is the default value of one of the stored procedure's parameters. I suggest using Script As to get the TSQL definition of the stored procedure from the database and verifying that the stored procedure default values match what's in your database project.
Also, note that there have been a large number of bug fixes to schema comparison that aren't available in VS2010. Have you considered installing the latest version of Visual Studio 2015 Express with SSDT?
I finally found a workaround. You simply script the affected SP(s) for Modify and run the Alter statement, without changing anything. It corrects the values.
I tried to do data compare with Visual Studio 2012 but got 1 critical error. I was able to to do the comparison between these 2 db before I was forced to update the data compare since I am comparing with another db using SQL 2014. My latest SQL Server Data Tools ver is 11.1.40403.0
Please see below for the screen shot. Has anybody encounter this before and has solution? I am stuck as data compare doesn't has any option to select to bypass constraint check or whatsoever.
Problem is solved automatically after restart PC.
We currently have an issue with our MSSQL 2005 database. We've recently undergone a migration from windows server 2003 to 2008. SQL Server has remained as 2005. I'm using SQL Server Management Studio to work on.
All the tables in the database follow the format: [SCHEMA].[TABLE_NAME]
When I enter the SQL:
SELECT * FROM [table_name]
I get the error message: Invalid object name '[table_name]'.
If I type in:
SELECT * FROM [schema].[table_name]
This works fine. The username we log into the database with owns the schema which is prepended to all the table names.
The problem is, we have 3rd party companies which have software which exports data from the database. 2 companies have now tried to run their exporters, however are getting the error 'Invalid object name'. The software is logging in with the username which owns the schema.
My question is exactly the same as this one I've found on the internet:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=99802
However the answer on that question seems to be full of keywords rather than actual sentences which makes it very hard to understand.
If anyone could help, it'd be greatly appreciated.
Many thanks
Phil
Set the default schema for the 3rd party's username to the schema their un-prefixed references should point to:
ALTER USER foo WITH DEFAULT_SCHEMA = [bar];
(This is different from owning the schema.)
And tell them to write software correctly. In SQL Server you should always be specifying the schema name, even if you always use dbo.
I am trying to export data from my production DB to my development DB but I am getting this error:
Messages Error 0xc0202049: Data Flow Task 1: Failure inserting into the
read-only column "id". (SQL Server Import and Export Wizard)
Is there a way to check which column is that because I have 20 tables that all of them use the column name id or at least get a better error report?
Just click on Edit mappings when you choose tables to import from and to. and check on the Enable identity insert checkbox. And you should do that for each choosen table. Then you can complete your import. It was helped me in the same situation.
If the column ID is an identity column, it's likely set up to generate automatically when a row is inserted, and is not able to be directly written to.
To preserve linking from the production environment to the test, use:
SET Identity_Insert <TableName> ON
To allow you to write identity values.
All I had to do was:
Right-click on the column (in this case 'ID')
Select Modify
Inside the Column Properties scroll down until you see Identity Specification
Expand the view and select NO from the drop down menu.
If anyone knows a different (faster) way of doing this please share
Sounds to me as though you might be trying to insert values into a column that has been declared as an IDENTITY field.
Well, the answer is a bit late but I'm posting it anyway for the sake of providing to community.
I assume that you are trying to copy tables (not partial data). My answer is based on this assumption.
Connect to the source db via Object Explorer in SSMS.
Right click the db that you want its tables to be copied.
Go to 'Tasks' --> 'Export'.
Choose your source and destination server and if you don't want additional script to be run before hands just press next ('Copy data from one or more tables or views'). Now you may select tables you want to be copied to the destination.
Select tables that you want to be completely copied to the destination. And click on 'edit mappings'. Here you may 'enable identity insert'. You will also have other options so check the screen before pressing OK.
If you do not use an express edition of SSMS here you may create an SSIS package to create jobs and to automatize this process in the future. You may check 'run immediately' and follow the screen about how it goes with all the warnings and errors. Hopefully you will get none. Good luck!
Tested with:
(
Microsoft SQL Server 2008 R2 (SP1) - 10.50.2500.0 (Intel X86)
Jun 17 2011 00:57:23
Copyright (c) Microsoft Corporation
Enterprise Edition on Windows NT 5.2 <X86> (Build 3790: Service Pack 2)
)
EDIT2: Found a fix! I used the number of the desired schema instead of the name. Should've thought of that before, really! And i think the error messages could've been a bit better aswell. Thanks for all your time!
How can i get the names of all tables inside a database through sql inside asp classic?
The server is running windows 2008, iis7.5 and microsoft jet. I've tried all the querys i could find on the internet (and here) but none have worked.
If i add a ; to the query to run a set of querys at the same time it gives me an error because the statement isn't over at the semicolon.
The master.mdf database cannot be accessed because it's of unknown format.
The sysobjects variable apparently doesn't exist.
I am using mssql 2000 format. (.mdf)
The connection is made through classic asp with the Microsoft.Jet.OLEDB.4.0 provider and ADODB connection/recordset.
How do I get list of all tables in a database using TSQL?
Query to get the names of all tables in SQL Server 2008 Database
EDIT:
I've found two folders containing databases. One is in C:\program files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\mssql\binn\templates and contains master.mdf, mastlog.ldf, model.mdf, modellog.ldf, msdbdata.mdf and msdblog.ldf. The other one is also in the \binn\template data directory and contains master.mdf, mastlog.ldf, model.mdf, modellog.ldf, MSDBData.mdf, MSDBLog.ldf, mssqlsystemresource.ldf, mssqlsystemresource.mdf, tempdb.mdf and templog.ldf. Maybe these is of some interest?
How can i tell if i have permission? Does it give a permission denied error?
Please help! No, don't. Read the 2nd edit at the top.
USE YOUR_DATABASE
GO
SELECT *
FROM sys.Tables
GO
Have you tried the example from:
http://www.kamath.com/codelibrary/cl002_listtables.asp
I almost always use the INFORMATION_SCHEMA views:
SELECT * FROM INFORMATION_SCHEMA.TABLES
If this isn't working for you, the SQL user your site is running under may not have access to the system objects. This is actually a good thing, as giving your site access to the underlying database schema can leave you vulnerable to SQL injection.
So if you do go this route, proceed with caution.
The mdf by itself is useless: you need a database engine (a.k.a. a SQL Server instance) to "run" it. As I understand the question, this is your problem.
Then you can use sysobjects in your database: unless you have added your tables to the master database
There is no practical way to use an mdf directly: if nothing else download MSDE