Object cannot be cast from DBNull to other types
Yann
Posts: 3
Hi,
Each time I want to compare my two databases, I have got the following error:
Object cannot be cast from DBNull to other types.
It's during the first step:
Registering databases
MYSERVER.MYDB-Reading columns.
Why i am having that? any idea?
Thx a lot,
Yann.
Each time I want to compare my two databases, I have got the following error:
Object cannot be cast from DBNull to other types.
It's during the first step:
Registering databases
MYSERVER.MYDB-Reading columns.
Why i am having that? any idea?
Thx a lot,
Yann.
This discussion has been closed.
Comments
Sorry, I don't know. When this happens, it's usually because the request for schema information from the database is returning (or not returning any) data that is invalid.
If you have purchased the product, I'd recommend contacting support@red-gate.com so we can look deeper into it.
In fact, when SQCompare tries to "Retieving schema", I got the error.
What your application really do during the step "reading columns"?
Thx,
Yann.
I think the first thing to try would be to check the database for curruption using DBCC CHECKDB.
I used Management Studio to generate a script for each database. I chose all SPs, all Tables and all Users. Both scripts were generated successfully.
As Brian's post cited an IDENTITY issue, I searched both scripts and the IDENTITY(1,1) is correct an all tables (there are only 5 User tables in this DB, so the script and DB is miniscule).
Should a support issue be opened?
Decide wisely...
CREATE TABLE [dbo].Group](
[GroupId] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](80) NOT NULL,
[Description] [nvarchar](255) NULL,
CONSTRAINT [PK__[Group]]__76CBA758] PRIMARY KEY NONCLUSTERED
(
[GroupId] ASC
) ON [PRIMARY]
) ON [PRIMARY]
Inrestingly enough, SQL Prettifier barfs on this... and only gives:
CREATE TABLE [dbo].Group](
[GroupId] [int
in the rendered HTML...
OPINION: Parsing is upset by the 3rd ']' after the table name, Group (Group being a reserved word, it must be terminated by an additional ].)
I verified this by:
1. Creating a new DB and adding the Group table to it. All tools barfed.
2. DROP the table and add it back as Group_SLA, with only and surrounding the table name. Table definition is now readable...
Decide wisely...
It would also be REALLY USEFUL if, despite my Profile being HTML=Yes, the HTML option for my posts were ON, so I could post Prettifier output here
Decide wisely...
CREATE TABLE [dbo].[Group_SLA](
[GroupId] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](80) NOT NULL,
[Description] [nvarchar](255) NULL,
CONSTRAINT [PK__[Group]]__76CBA758] PRIMARY KEY NONCLUSTERED
(
[GroupId] ASC
) ON [PRIMARY]
) ON [PRIMARY]
Decide wisely...
Editing maybe, I'm told allowing HTML code is potentially dangerous, so you're limited to BBCODE. Anyway, about this... Do you mean to have the end-bracket (deleimiter) in there twice? The only other thing I see could be a BIT suspicious is that you create the primary key index on PRIMARY inside the create table DDL, which is also being created on PRIMARY.
I'll put that into a SQL database tomorrow morning and see if it throws me a curve with SQL Data Compare.
Disclaimer: A consulting firm wrote the app. - I would NEVER use a reserved word as a table name 8)
Onwards...:
Having DROPped the Group_SLA table, I used this SQL: It's a bare-bones table, no constraints or indexes...
Back to SQL Data Compare to run the compare on my test DB vs. a Development version - it croaks (thankfully).
If only I could insert a jpg, I could show you the dialog box... But, the process fails at "Registering databases" and shows the failing db as (local).UserAccount-Reading columns
As my test table is the only user-object there, I posited on the 3rd ]]] on the 1st line of the Create DDL being the Prettifier parser's likely stumbling block and that there may some issue with the SQL Compare tools handling a reserved word, i.e., []bounded. Wild guess maybe... but it seems the only difference that causes a problem is the use of a reserved word...
Hope this helps.
Decide wisely...