Showing posts with label delete. Show all posts
Showing posts with label delete. Show all posts

Sunday, March 25, 2012

Analysis Server Database has errors. Cant delete, can't view

I tried to import a abf file in my Analysis Services using the wizard. It didn't succeed completely as I ran out of disk space. However it left my AS database in inconsistent state. I can't view anything. Can't delete anything. The entire AS is unusable at the moment. I get the following error.

"Errors in metadata manager. The dimension with ID of v_Contract, Name of Contract referenced by 'GPC GL Cube' does not exist......"

Please let me know how to restore my AS so that I can retry importing the database.

Thanks,

Ashish

I was able to remove the database. I had to stop the AS and delete the physical folders. Then restarted the AS and I was able to delete the Databases.

Hope this helps someone else because I spent some time trying to figure this out.

Ashish

Tuesday, March 20, 2012

An workaround (was The Answer (was Re: UDA and SQL Data Access))

Is it possible for a user-defined aggregate to perform basic DML operations through ADO.NET (read, update, insert, delete)?

Why would I want to do that, you might ask? Rather than carry forward an accumulation of data, what I want to do is insert the data into a temporary table and retrieve it at the Terminate method call.

I created an aggregate to do the above using VS2005. My aggregate compiles, and deploys through VS2005, but I get the following error when I attempt to run it in debugger:

Data access is not allowed in this context. Either the context is a function or method not marked with DataAccessKind.Read or SystemDataAccessKind.Read, is a callback to obtain data from FillRow method of a Table Valued Function, or is a UDT validation method.

All functions in UDA must be compatible with User Defined Functions. But UDFs couldn't consist update/insert/delete DML. So I couldn't use them in context connection. But you could create different connection and run update statements through it.

|||

I tried a couple of different options, but it appears that the user-defined aggregates are prohibited from having any kind of connection via SQLCLR in the database.

I have not been able to find any documentation to support or refute this claim, but it appears that UDAs are severely limited in SQL Server 2005.

|||

I finally found a reference that specifies an answer to the question of whether user-defined aggregates can perform database access or not. The answer is "No".

I quote from the Microsoft Whitepaper, Using CLR Integration in SQL Server 2005 (Rathakrishnan, et al.):

A "UDA can perform no data access, nor have side-effects; if either of these are necessary then a stored procedure should be used.UDA can perform no data access, nor have side-effects; if either of these are necessary then a stored procedure should be used."

Thus UDAs have some significant limitations in this version of SQL Server. They are:

No data access|||

vb_hal,

I have been dealing with the same problems as you. In my case, I wanted to create an UDA for calculating the percentile of a set of numbers (as in the PERCENTILE function in Excel).

What I wished for was to be able to write something like

SELECT dbo.PERCENTILE(some_column, 0.5)

FROM some_table

GROUP BY some_other_column

To work arround the multiple arguments problem, I created an UDT called PercentileParameters and an UDF called PP that acts as a sort of constructor. As a result, the query now looks like this:

SELECT dbo.PERCENTILE( dbo.PP(some_column, 0.5) )

FROM some_table

GROUP BY some_other_column

I also had some trouble with the 8000 bytes limit. To work arround it, I gave my assembly EXTERNAL_ACCESS rights and used them to store data as needed. I know it's not very efficient, and that it's impossible in some settings due to security issues, but it works for me.

So there you go. I just thought I'd share these couple ideas with people facing the same problems as I am (and are looking for a quick and dirty way out of it, just as I was).

--

Carlos

|||

I've been trying to find exactly what you seem to have. I've been looking for a function in SQL Server that does the same thing as PERCENTILE in Excel. Oracle has an implementation called PERCENTILE_CONT and I've seen ways to do the calculations in SQL Server 2005 but not as a function. Is there any way you could share your code with me?

From the documentation I've read on UDAs, I'd have to create an assembly in a .Net language to create my own aggregate. Quite a daunting task from my perspective since my background is strictly SQL Server code and Admin. I could get around the multivalued function issue because I use 5 static percentile values (.1,.25,.5,.75,.9). I could just create 5 UDAs.

Any feedback is greatly appreciated.

blackjackIT

|||

Jourdan, can you shaer your dbo.Percentile and dbo.PP function if possible. I'm trying to do the same UDA for percentile as you.

Thanks!

An workaround (was The Answer (was Re: UDA and SQL Data Access))

Is it possible for a user-defined aggregate to perform basic DML operations through ADO.NET (read, update, insert, delete)?

Why would I want to do that, you might ask? Rather than carry forward an accumulation of data, what I want to do is insert the data into a temporary table and retrieve it at the Terminate method call.

I created an aggregate to do the above using VS2005. My aggregate compiles, and deploys through VS2005, but I get the following error when I attempt to run it in debugger:

Data access is not allowed in this context. Either the context is a function or method not marked with DataAccessKind.Read or SystemDataAccessKind.Read, is a callback to obtain data from FillRow method of a Table Valued Function, or is a UDT validation method.

All functions in UDA must be compatible with User Defined Functions. But UDFs couldn't consist update/insert/delete DML. So I couldn't use them in context connection. But you could create different connection and run update statements through it.

|||

I tried a couple of different options, but it appears that the user-defined aggregates are prohibited from having any kind of connection via SQLCLR in the database.

I have not been able to find any documentation to support or refute this claim, but it appears that UDAs are severely limited in SQL Server 2005.

|||

I finally found a reference that specifies an answer to the question of whether user-defined aggregates can perform database access or not. The answer is "No".

I quote from the Microsoft Whitepaper, Using CLR Integration in SQL Server 2005 (Rathakrishnan, et al.):

A "UDA can perform no data access, nor have side-effects; if either of these are necessary then a stored procedure should be used.UDA can perform no data access, nor have side-effects; if either of these are necessary then a stored procedure should be used."

Thus UDAs have some significant limitations in this version of SQL Server. They are:

No data access|||

vb_hal,

I have been dealing with the same problems as you. In my case, I wanted to create an UDA for calculating the percentile of a set of numbers (as in the PERCENTILE function in Excel).

What I wished for was to be able to write something like

SELECT dbo.PERCENTILE(some_column, 0.5)

FROM some_table

GROUP BY some_other_column

To work arround the multiple arguments problem, I created an UDT called PercentileParameters and an UDF called PP that acts as a sort of constructor. As a result, the query now looks like this:

SELECT dbo.PERCENTILE( dbo.PP(some_column, 0.5) )

FROM some_table

GROUP BY some_other_column

I also had some trouble with the 8000 bytes limit. To work arround it, I gave my assembly EXTERNAL_ACCESS rights and used them to store data as needed. I know it's not very efficient, and that it's impossible in some settings due to security issues, but it works for me.

So there you go. I just thought I'd share these couple ideas with people facing the same problems as I am (and are looking for a quick and dirty way out of it, just as I was).

--

Carlos

|||

I've been trying to find exactly what you seem to have. I've been looking for a function in SQL Server that does the same thing as PERCENTILE in Excel. Oracle has an implementation called PERCENTILE_CONT and I've seen ways to do the calculations in SQL Server 2005 but not as a function. Is there any way you could share your code with me?

From the documentation I've read on UDAs, I'd have to create an assembly in a .Net language to create my own aggregate. Quite a daunting task from my perspective since my background is strictly SQL Server code and Admin. I could get around the multivalued function issue because I use 5 static percentile values (.1,.25,.5,.75,.9). I could just create 5 UDAs.

Any feedback is greatly appreciated.

blackjackIT

|||

Jourdan, can you shaer your dbo.Percentile and dbo.PP function if possible. I'm trying to do the same UDA for percentile as you.

Thanks!

An workaround (was The Answer (was Re: UDA and SQL Data Access))

Is it possible for a user-defined aggregate to perform basic DML operations through ADO.NET (read, update, insert, delete)?

Why would I want to do that, you might ask? Rather than carry forward an accumulation of data, what I want to do is insert the data into a temporary table and retrieve it at the Terminate method call.

I created an aggregate to do the above using VS2005. My aggregate compiles, and deploys through VS2005, but I get the following error when I attempt to run it in debugger:

Data access is not allowed in this context. Either the context is a function or method not marked with DataAccessKind.Read or SystemDataAccessKind.Read, is a callback to obtain data from FillRow method of a Table Valued Function, or is a UDT validation method.

All functions in UDA must be compatible with User Defined Functions. But UDFs couldn't consist update/insert/delete DML. So I couldn't use them in context connection. But you could create different connection and run update statements through it.

|||

I tried a couple of different options, but it appears that the user-defined aggregates are prohibited from having any kind of connection via SQLCLR in the database.

I have not been able to find any documentation to support or refute this claim, but it appears that UDAs are severely limited in SQL Server 2005.

|||

I finally found a reference that specifies an answer to the question of whether user-defined aggregates can perform database access or not. The answer is "No".

I quote from the Microsoft Whitepaper, Using CLR Integration in SQL Server 2005 (Rathakrishnan, et al.):

A "UDA can perform no data access, nor have side-effects; if either of these are necessary then a stored procedure should be used.UDA can perform no data access, nor have side-effects; if either of these are necessary then a stored procedure should be used."

Thus UDAs have some significant limitations in this version of SQL Server. They are:

No data access|||

vb_hal,

I have been dealing with the same problems as you. In my case, I wanted to create an UDA for calculating the percentile of a set of numbers (as in the PERCENTILE function in Excel).

What I wished for was to be able to write something like

SELECT dbo.PERCENTILE(some_column, 0.5)

FROM some_table

GROUP BY some_other_column

To work arround the multiple arguments problem, I created an UDT called PercentileParameters and an UDF called PP that acts as a sort of constructor. As a result, the query now looks like this:

SELECT dbo.PERCENTILE( dbo.PP(some_column, 0.5) )

FROM some_table

GROUP BY some_other_column

I also had some trouble with the 8000 bytes limit. To work arround it, I gave my assembly EXTERNAL_ACCESS rights and used them to store data as needed. I know it's not very efficient, and that it's impossible in some settings due to security issues, but it works for me.

So there you go. I just thought I'd share these couple ideas with people facing the same problems as I am (and are looking for a quick and dirty way out of it, just as I was).

--

Carlos

|||

I've been trying to find exactly what you seem to have. I've been looking for a function in SQL Server that does the same thing as PERCENTILE in Excel. Oracle has an implementation called PERCENTILE_CONT and I've seen ways to do the calculations in SQL Server 2005 but not as a function. Is there any way you could share your code with me?

From the documentation I've read on UDAs, I'd have to create an assembly in a .Net language to create my own aggregate. Quite a daunting task from my perspective since my background is strictly SQL Server code and Admin. I could get around the multivalued function issue because I use 5 static percentile values (.1,.25,.5,.75,.9). I could just create 5 UDAs.

Any feedback is greatly appreciated.

blackjackIT

|||

Jourdan, can you shaer your dbo.Percentile and dbo.PP function if possible. I'm trying to do the same UDA for percentile as you.

Thanks!

Monday, March 19, 2012

An internal error occurred. [ ID = 3639 ] on delete query

Hi,

When I am trying to execute a delete query i'm getting the following error An internal error occurred. [ ID = 3639 ]. This is happening for some specific rows only. Other rows are getting deleted without any issues. Some 7 rows are there which i'm not able to delete. I am able to run update query on that rows. but not delete query

Pls help

Thanks

Nebu

This error does not look like a SQL CE error. Are you using SQL CE or SQL Server ?

Also, could you show us the statement and describe your environment, then others may be able to help you.

|||I'm using SQL CE.

delete from tabl1 where ID=1

We are using SLQ ce as a databse for a windows application. We use C# . Some times there will be insert and delete statements of more than 10000. I executed this statement for more than 10000 records, in that apart from 7 records every thing else got deleted. I'm not able to delete it even from SQL server management studio expresss.

tahnks

Nebu

|||Sounds like your sdf file has become corrupted. Try to run a Compact/Repair on the db. You can also try to send the sdf file to me, and I will have a look at it with SSMS.

|||

Hi Erik,

Thanks for the reply. I will not able to send you the sdf bcos of confidentiality. Can you please tell me how to run a reapir?

Thanks

Nebu

|||

Repair can be done from SSMS(E), right click the database, select Properties and the Shrink/Repair tab.

Also, the SqlCeEngine object has a Repair method.

|||Thanks Eirk.. It worked.. Do you have any idea why did it happen? Is it

because of the no of transactions?

Thanks

Nebu

Sunday, March 11, 2012

An EXCEPTION_ACCESS_VIOLATION during a DELETE...

Our customers server uses SQLServer 7sp4. I don't know too much about the
hardware other than that they have 2gb RAM. Running the DELETE command
below yields an EXCEPTION_ACCESS_VIOLATION and the spid is terminated.
(SqlDumpExceptionHandler: Process 9 generated fatal exception c0000005
EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.)
DELETE RSCONFIG WHERE ConfigType IN (1, 2, 3) AND SUBSTRING(ConfigKey,1,3)
IN ('265', '266')
We had them run a DBBC CHECKDB on this database, and eveything is fine. The
"ConfigType" is a smallint and the "ConfigKey" is a varchar(32).
What might this be? We know we have valid SQL and that it has run on many
many of our customers servers.
Any words or ideas will be greatly appreciated. Thanks in advance for your
time.
Sincerely,
James Hunter Ross
Senior Software Developer
O'Neil Software, Inc.This indicates an internal error in sql server. It also indicates it's time
to call PSS (i.e. MS support).
--
Carlos E. Rojas
SQL Server MVP
Co-Author SQL Server 2000 programming by Example
"James Hunter Ross" <james.ross@.oneilsoft.com> wrote in message
news:OG%23ko8f5DHA.2580@.TK2MSFTNGP11.phx.gbl...
quote:

> Our customers server uses SQLServer 7sp4. I don't know too much about the
> hardware other than that they have 2gb RAM. Running the DELETE command
> below yields an EXCEPTION_ACCESS_VIOLATION and the spid is terminated.
> (SqlDumpExceptionHandler: Process 9 generated fatal exception c0000005
> EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.)
> DELETE RSCONFIG WHERE ConfigType IN (1, 2, 3) AND SUBSTRING(ConfigKey,1,3)
> IN ('265', '266')
> We had them run a DBBC CHECKDB on this database, and eveything is fine.

The
quote:

> "ConfigType" is a smallint and the "ConfigKey" is a varchar(32).
> What might this be? We know we have valid SQL and that it has run on many
> many of our customers servers.
> Any words or ideas will be greatly appreciated. Thanks in advance for

your
quote:

> time.
> Sincerely,
> James Hunter Ross
> Senior Software Developer
> O'Neil Software, Inc.
>

An EXCEPTION_ACCESS_VIOLATION during a DELETE...

Our customers server uses SQLServer 7sp4. I don't know too much about the
hardware other than that they have 2gb RAM. Running the DELETE command
below yields an EXCEPTION_ACCESS_VIOLATION and the spid is terminated.
(SqlDumpExceptionHandler: Process 9 generated fatal exception c0000005
EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.)
DELETE RSCONFIG WHERE ConfigType IN (1, 2, 3) AND SUBSTRING(ConfigKey,1,3)
IN ('265', '266')
We had them run a DBBC CHECKDB on this database, and eveything is fine. The
"ConfigType" is a smallint and the "ConfigKey" is a varchar(32).
What might this be? We know we have valid SQL and that it has run on many
many of our customers servers.
Any words or ideas will be greatly appreciated. Thanks in advance for your
time.
Sincerely,
James Hunter Ross
Senior Software Developer
O'Neil Software, Inc.This indicates an internal error in sql server. It also indicates it's time
to call PSS (i.e. MS support).
--
Carlos E. Rojas
SQL Server MVP
Co-Author SQL Server 2000 Programming by Example
"James Hunter Ross" <james.ross@.oneilsoft.com> wrote in message
news:OG%23ko8f5DHA.2580@.TK2MSFTNGP11.phx.gbl...
> Our customers server uses SQLServer 7sp4. I don't know too much about the
> hardware other than that they have 2gb RAM. Running the DELETE command
> below yields an EXCEPTION_ACCESS_VIOLATION and the spid is terminated.
> (SqlDumpExceptionHandler: Process 9 generated fatal exception c0000005
> EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.)
> DELETE RSCONFIG WHERE ConfigType IN (1, 2, 3) AND SUBSTRING(ConfigKey,1,3)
> IN ('265', '266')
> We had them run a DBBC CHECKDB on this database, and eveything is fine.
The
> "ConfigType" is a smallint and the "ConfigKey" is a varchar(32).
> What might this be? We know we have valid SQL and that it has run on many
> many of our customers servers.
> Any words or ideas will be greatly appreciated. Thanks in advance for
your
> time.
> Sincerely,
> James Hunter Ross
> Senior Software Developer
> O'Neil Software, Inc.
>

An exception was thrown while trying to delete a maintenance plan.

Receive a message that an exception was thrown while trying to delete a
maintenance plan.
SQL 2005 with spk 2aSQLdba wrote:
> Receive a message that an exception was thrown while trying to delete a
> maintenance plan.
> SQL 2005 with spk 2a
I posted a message yesterday regarding this problem. :-)
I believe you've created that maintenance plan under either different
user or the same user with different password. If former, connect with
the same user, if latter - change the password, delete the MP and then
change the password back.

An exception was thrown while trying to delete a maintenance plan.

Receive a message that an exception was thrown while trying to delete a
maintenance plan.
SQL 2005 with spk 2a
SQLdba wrote:
> Receive a message that an exception was thrown while trying to delete a
> maintenance plan.
> SQL 2005 with spk 2a
I posted a message yesterday regarding this problem. :-)
I believe you've created that maintenance plan under either different
user or the same user with different password. If former, connect with
the same user, if latter - change the password, delete the MP and then
change the password back.

Saturday, February 25, 2012

AMO: Only need to use ProcessData?

Hi, friends, please look at this:

I add and delete some data records into the FactTable in the SQL Server(Not changing any structure), and want to process the cube by AMO. I only need to use the ProcessData on the cube, right?

I add and delete some data records into the DimentionTable in the SQL Server(Not changing any structure), and want to process the cube by AMO. I only need to use the ProcessUpdate on the dimention , right?,

Moved to Analysis Services|||please have a look. Thanks.|||

ivanchain wrote:

I add and delete some data records into the FactTable in the SQL Server(Not changing any structure), and want to process the cube by AMO. I only need to use the ProcessData on the cube, right?

You would also need to do a processIndex to get the aggregations and indexes processed (the cube would work, but could be quite slow if you have designed aggregations but don't do this)

ivanchain wrote:

I add and delete some data records into the DimentionTable in the SQL Server(Not changing any structure), and want to process the cube by AMO. I only need to use the ProcessUpdate on the dimention , right?,

Yes, ProcessUpdate is all you need to do to add/delete/update records in a dimension table.

|||

Thanks!

AMO: Only need to use ProcessData?

Hi, friends, please look at this:

I add and delete some data records into the FactTable in the SQL Server(Not changing any structure), and want to process the cube by AMO. I only need to use the ProcessData on the cube, right?

I add and delete some data records into the DimentionTable in the SQL Server(Not changing any structure), and want to process the cube by AMO. I only need to use the ProcessUpdate on the dimention , right?,

Moved to Analysis Services|||please have a look. Thanks.|||

ivanchain wrote:

I add and delete some data records into the FactTable in the SQL Server(Not changing any structure), and want to process the cube by AMO. I only need to use the ProcessData on the cube, right?

You would also need to do a processIndex to get the aggregations and indexes processed (the cube would work, but could be quite slow if you have designed aggregations but don't do this)

ivanchain wrote:

I add and delete some data records into the DimentionTable in the SQL Server(Not changing any structure), and want to process the cube by AMO. I only need to use the ProcessUpdate on the dimention , right?,

Yes, ProcessUpdate is all you need to do to add/delete/update records in a dimension table.

|||

Thanks!

AMO: Looping to delete partitions

Hi

I am trying - in AMO code - to loop over the partitions in my different measure groups and drop these. But apparently I am not allowed to do it with the following code, since I am modifying the collection which I am looping (because I drop the partitions which exist in the collection).

....

For Each oMeasuregroup in oCube.MeasureGroups

For Each oPartition in oMeasureGroup.Partitions

oPartition.Drop()

Next

Next

...

Can anyone help me with a solution? Thanks.

Hi,

You need to iterate over the partitions collection with integer index.

PartitionCollection partitions = ...;

for( int i=partitions.Count-1; i>=0; --i )
partitions[ i ].Drop();

Adrian Dumitrascu

Friday, February 24, 2012

AMO: Could I processfull on a measuregroup ONLY?

hi, friends,

I add/delete a measure in AMO. I want to know I need to processfull the whole cube or ONLY the measuregroup that associated?

Thanks!

I am quoting the Darren Gospbell's Reply to this quetion raised earlier in this forum:

"If you add a measure you are changing the structure of the cube which will invalidate the cube, the easiest way to get the cube "fully operational" again would be to do a processFull. The same thing applies when removing a measure.

Thanks

Subhash Subramanyam

|||

You mean that I need to process the WHOLE cube?

But I only process the measuregroup associated to the measure I just added, and no error reported.

I still think I need only to process the measuregroup associated.

What do you think?

Thanks.

|||

You only need to process the MeasureGroup. It is true that adding or removing a measure is a structural change that would clear the data (so re-processing is required), but the MeasureGroup is the most immediate parent containing the Partitions (who store the actual data) and Aggregations (who would need to be re-generated), so processing just the MeasureGroup should be enough.

But when saving the MeasureGroup (because you deleted the Measure), you might need to re-save the entire cube (with the ExpandFull option passed to the Update method) if you have Perspectives objects using that Measure.

Adrian Dumitrascu

|||

Thank you all!

AMO: Could I processfull on a measuregroup ONLY?

hi, friends,

I add/delete a measure in AMO. I want to know I need to processfull the whole cube or ONLY the measuregroup that associated?

Thanks!

I am quoting the Darren Gospbell's Reply to this quetion raised earlier in this forum:

"If you add a measure you are changing the structure of the cube which will invalidate the cube, the easiest way to get the cube "fully operational" again would be to do a processFull. The same thing applies when removing a measure.

Thanks

Subhash Subramanyam

|||

You mean that I need to process the WHOLE cube?

But I only process the measuregroup associated to the measure I just added, and no error reported.

I still think I need only to process the measuregroup associated.

What do you think?

Thanks.

|||

You only need to process the MeasureGroup. It is true that adding or removing a measure is a structural change that would clear the data (so re-processing is required), but the MeasureGroup is the most immediate parent containing the Partitions (who store the actual data) and Aggregations (who would need to be re-generated), so processing just the MeasureGroup should be enough.

But when saving the MeasureGroup (because you deleted the Measure), you might need to re-save the entire cube (with the ExpandFull option passed to the Update method) if you have Perspectives objects using that Measure.

Adrian Dumitrascu

|||

Thank you all!

AMO: Can''t update dsv when delete a column

Hi, friends, please have a look at this:

I am using AMO, and I do this:

1 step: I drop a column from the source table by SQL:

ALTER TABLE TargetTable Drop COLUMN ColumnName

2 step: I try to update the dsv by AMO:

Dim adapter As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter( _
"SELECT * FROM [dbo].[" + tableName + "] WHERE 1=0", connection)
Dim i As Integer

For i = 0 To dsv.Schema.Tables.Count - 1
If dsv.Schema.Tables(i).TableName = "dbo_" & tableName Then
MessageBox.Show("Before dsv.Schema.Tables.Count:" & dsv.Schema.Tables(i).Columns.Count)
Dim dataTable As DataTable = adapter.FillSchema(dsv.Schema.Tables(i), SchemaType.Mapped)
MessageBox.Show("After dsv.Schema.Tables.Count:" & dsv.Schema.Tables(i).Columns.Count)
End If

Next

But, from the first messagebox and the second messagebox, I see the dsv is not updated after I delete the column.

3 step: I save the dsv to the server.

If Mainform.tDatabase.DataSourceViews.Count > 0 Then
Mainform.tDatabase.DataSourceViews(0).Update(Microsoft.AnalysisServices.UpdateOptions.ExpandFull)
End If

Then I check the server, the dsv still include the columnname I have deleted.

Why and how to update the dsv after I delete a column?

Thanks!

ivanchain wrote:

Dim dataTable As DataTable = adapter.FillSchema(dsv.Schema.Tables(i), SchemaType.Mapped)

ivanchain wrote:

But, from the first messagebox and the second messagebox, I see the dsv is not updated after I delete the column

Let's also check if the returned 'dataTable' still contains the column you deleted. If it does contain the column, then we need to double check the table name and its columns in SQL Server.If the returned 'dataTable' doesn't contain the column, it looks like you need to replace the table in the DSV with this returned 'dataTable', but according to documentation at http://msdn2.microsoft.com/en-us/library/152bda9x.aspx, this should not be the case.

The rest of the code looks good, the problem is not in AMO, but in the FillSchema area.

Adrian Dumitrascu

|||

I tried what you said:

Let's also check if the returned 'dataTable' still contains the column you deleted. If it does contain the column, then we need to double check the table name and its columns in SQL Server.

Yes, the returned 'dataTable' still contains the column I deleted. But I don't know what you exactly mean of DOUBLE CHECK the table name and its columns in SQL Server? I need to check what?

Thank you!

|||

The problem is still there.... help!

thanks.

|||

The only ideas that I have are:

- double check that the database name (that you use in the code) is the same with the database on which you removed the column from the table. There might be a concidence that you have 2 databases containing the same table name and column name, you deleted from one, but the code works on the other database by chance (since I don't see in the code where you explicitly chose the database on which to run the SELECT statement)

- double check that the name and the schema, 'dbo', of the table you use in the code are the same as the schema and the name of the table from which you deleted the column

|||

Thanks, Adrian. But, I don't think it's about the NAME of the table. Because my code could update dsv when I add a column into the SQL table in the SQL Server. If the name of the table is wrong, it will also not update when adding, right?

Thanks!

AMO: Can't update dsv when delete a column

Hi, friends, please have a look at this:

I am using AMO, and I do this:

1 step: I drop a column from the source table by SQL:

ALTER TABLE TargetTable Drop COLUMN ColumnName

2 step: I try to update the dsv by AMO:

Dim adapter As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter( _
"SELECT * FROM [dbo].[" + tableName + "] WHERE 1=0", connection)
Dim i As Integer

For i = 0 To dsv.Schema.Tables.Count - 1
If dsv.Schema.Tables(i).TableName = "dbo_" & tableName Then
MessageBox.Show("Before dsv.Schema.Tables.Count:" & dsv.Schema.Tables(i).Columns.Count)
Dim dataTable As DataTable = adapter.FillSchema(dsv.Schema.Tables(i), SchemaType.Mapped)
MessageBox.Show("After dsv.Schema.Tables.Count:" & dsv.Schema.Tables(i).Columns.Count)
End If

Next

But, from the first messagebox and the second messagebox, I see the dsv is not updated after I delete the column.

3 step: I save the dsv to the server.

If Mainform.tDatabase.DataSourceViews.Count > 0 Then
Mainform.tDatabase.DataSourceViews(0).Update(Microsoft.AnalysisServices.UpdateOptions.ExpandFull)
End If

Then I check the server, the dsv still include the columnname I have deleted.

Why and how to update the dsv after I delete a column?

Thanks!

ivanchain wrote:

Dim dataTable As DataTable = adapter.FillSchema(dsv.Schema.Tables(i), SchemaType.Mapped)

ivanchain wrote:

But, from the first messagebox and the second messagebox, I see the dsv is not updated after I delete the column

Let's also check if the returned 'dataTable' still contains the column you deleted. If it does contain the column, then we need to double check the table name and its columns in SQL Server.If the returned 'dataTable' doesn't contain the column, it looks like you need to replace the table in the DSV with this returned 'dataTable', but according to documentation at http://msdn2.microsoft.com/en-us/library/152bda9x.aspx, this should not be the case.

The rest of the code looks good, the problem is not in AMO, but in the FillSchema area.

Adrian Dumitrascu

|||

I tried what you said:

Let's also check if the returned 'dataTable' still contains the column you deleted. If it does contain the column, then we need to double check the table name and its columns in SQL Server.

Yes, the returned 'dataTable' still contains the column I deleted. But I don't know what you exactly mean of DOUBLE CHECK the table name and its columns in SQL Server? I need to check what?

Thank you!

|||

The problem is still there.... help!

thanks.

|||

The only ideas that I have are:

- double check that the database name (that you use in the code) is the same with the database on which you removed the column from the table. There might be a concidence that you have 2 databases containing the same table name and column name, you deleted from one, but the code works on the other database by chance (since I don't see in the code where you explicitly chose the database on which to run the SELECT statement)

- double check that the name and the schema, 'dbo', of the table you use in the code are the same as the schema and the name of the table from which you deleted the column

|||

Thanks, Adrian. But, I don't think it's about the NAME of the table. Because my code could update dsv when I add a column into the SQL table in the SQL Server. If the name of the table is wrong, it will also not update when adding, right?

Thanks!