Showing posts with label key. Show all posts
Showing posts with label key. Show all posts

Tuesday, March 27, 2012

Cant Cascade Delete

I have a Sql Server 2005 table with 3 fields, an ID field (primary key), a parent ID field, and Name. The parent ID references the ID field (foreign to primary - many to one) within the same table so that records can reference their parent. I would like to place a cascade delete on the ID field so that when the primary ID is removed it will automatically remove all those records with a parent ID that match. Sql server does not allow me to establish this cascade delete.

I was considering a trigger instead but only know how tio use the AFTER paramter and not an alternative.

Thanks

Hello my friend,

I see that you have a tree-like table. You have records that have a parent record, that can have a parent record that can have a parent record in the same table, and so on. The function at the bottom will help. You will need to change the table name from tblTree and the field names ParentID and PageID to whatever you have called them.

Anyway, the function will return a list of all child records. For example, if PageID 2 had childs 5 and 8, and 5 had 3 childs 67, 68, and 70, the resultset would look like the following: -

2
5
67
68
70
8

All you need to do is run a delete against this returned set as follows, which deletes number 2 and all of its children: -

DELETE FROM tblTree WHERE PageID IN (SELECT PageID FROM dbo.fnGetPages(2))

The function is as follows: -

CREATE FUNCTION dbo.fnGetPages
(
@.PageID AS INT
)

RETURNS @.ChildPageIDs TABLE(PageID INT)

AS

BEGIN
INSERT INTO @.ChildPageIDs (PageID)
SELECT PageID FROM tblTree WHERE ParentID = @.PageID

DECLARE @.TempChildPageIDs TABLE(PageID INT)
INSERT INTO @.TempChildPageIDs (PageID)
SELECT PageID FROM @.ChildPageIDs ORDER BY PageID

DECLARE @.ChildPageID AS INT
SET @.ChildPageID = (SELECT TOP 1 PageID FROM @.TempChildPageIDs)

WHILE (@.ChildPageID IS NOT NULL)
BEGIN
INSERT INTO @.ChildPageIDs (PageID)
SELECT PageID FROM dbo.fnGetPages(@.ChildPageID)
DELETE FROM @.TempChildPageIDs WHERE PageID = @.ChildPageID

SET @.ChildPageID = (SELECT TOP 1 PageID FROM @.TempChildPageIDs)
END
RETURN
END

If you have any questions on this, please let me know.

Kind regards

Scotty

|||Excellent stuff. Thank you!

Can't back up Encryption Key

I am trying to backup Encryption Key for my reporting service. Configuration tool, prompts for a encryption key file location and a strong password. When I provide the same and click OK, I get the following error:

ReportServicesConfigUI.WMIProvider.WMIProviderException: An unknown error has occurred in the WMI Provider. Error Code 80070A91

> System.Runtime.InteropServices.COMException (0x80070A91): Password doesn't meet the requirements of the filter dll's (Exception from HRESULT: 0x80070A91)
End of inner exception stack trace
at ReportServicesConfigUI.WMIProvider.RSReportServerAdmin.ThrowOnError(ManagementBaseObject mo)
at ReportServicesConfigUI.WMIProvider.RSReportServerAdmin.BackupEncryptionKey(Byte[]& encryptedBytes, String password)

I have tried with passwords with different combination but none of them seem to help. Any ideas?

It looks like your system has a password complexity filter installed. If you search on the error message, you will see a number of articles explaining how you can build and install one; I would check to see if that's the case first.

In the absence of a password filter, the RS WMI provider will use the local Windows password policy rules on Windows 2003

-Tudor

|||

Hi quantum_csfb

Have you had any luck resolving this?

I am getting the same error.

I am running XP Pro SP2.

Thanks.

|||

Gr8 :-)

Of course this was the thing.
Using a password that complied with the windows police in complexity worked fine

Many Thx

|||

Hi

I am also having the same problem of encryption key backup with same error message. I checked the Windows password policy and am adhering to that but still the same problem persists.

Any other suggestions?

Can't back up Encryption Key

I am trying to backup Encryption Key for my reporting service. Configuration tool, prompts for a encryption key file location and a strong password. When I provide the same and click OK, I get the following error:

ReportServicesConfigUI.WMIProvider.WMIProviderException: An unknown error has occurred in the WMI Provider. Error Code 80070A91

> System.Runtime.InteropServices.COMException (0x80070A91): Password doesn't meet the requirements of the filter dll's (Exception from HRESULT: 0x80070A91)
End of inner exception stack trace
at ReportServicesConfigUI.WMIProvider.RSReportServerAdmin.ThrowOnError(ManagementBaseObject mo)
at ReportServicesConfigUI.WMIProvider.RSReportServerAdmin.BackupEncryptionKey(Byte[]& encryptedBytes, String password)

I have tried with passwords with different combination but none of them seem to help. Any ideas?

It looks like your system has a password complexity filter installed. If you search on the error message, you will see a number of articles explaining how you can build and install one; I would check to see if that's the case first.

In the absence of a password filter, the RS WMI provider will use the local Windows password policy rules on Windows 2003

-Tudor

|||

Hi quantum_csfb

Have you had any luck resolving this?

I am getting the same error.

I am running XP Pro SP2.

Thanks.

|||

Gr8 :-)

Of course this was the thing.
Using a password that complied with the windows police in complexity worked fine

Many Thx

|||

Hi

I am also having the same problem of encryption key backup with same error message. I checked the Windows password policy and am adhering to that but still the same problem persists.

Any other suggestions?

Can't back up Encryption Key

I am trying to backup Encryption Key for my reporting service. Configuration tool, prompts for a encryption key file location and a strong password. When I provide the same and click OK, I get the following error:

ReportServicesConfigUI.WMIProvider.WMIProviderException: An unknown error has occurred in the WMI Provider. Error Code 80070A91

> System.Runtime.InteropServices.COMException (0x80070A91): Password doesn't meet the requirements of the filter dll's (Exception from HRESULT: 0x80070A91)
End of inner exception stack trace
at ReportServicesConfigUI.WMIProvider.RSReportServerAdmin.ThrowOnError(ManagementBaseObject mo)
at ReportServicesConfigUI.WMIProvider.RSReportServerAdmin.BackupEncryptionKey(Byte[]& encryptedBytes, String password)

I have tried with passwords with different combination but none of them seem to help. Any ideas?

It looks like your system has a password complexity filter installed. If you search on the error message, you will see a number of articles explaining how you can build and install one; I would check to see if that's the case first.

In the absence of a password filter, the RS WMI provider will use the local Windows password policy rules on Windows 2003

-Tudor

|||

Hi quantum_csfb

Have you had any luck resolving this?

I am getting the same error.

I am running XP Pro SP2.

Thanks.

|||

Gr8 :-)

Of course this was the thing.
Using a password that complied with the windows police in complexity worked fine

Many Thx

|||

Hi

I am also having the same problem of encryption key backup with same error message. I checked the Windows password policy and am adhering to that but still the same problem persists.

Any other suggestions?

Thursday, March 8, 2012

Cannot Update Identity Column while doing Select statement

Hi All,
i do have stored procedure
in which there select id,name from tablename
id i primary key and Identity seed is there for this column
When i directly query this statement it " select id,name from
tablename" , it shows the results
But when i call the same thing via stored procedure , it says Cannot
update identity colum
exec usp_getvalues , it gives the error
Thanks in Advance
Thomson
Hi
You would not expect this error from the query you have given therefore I
suspect that your stored procedure is doing something different. Post the
code for the store stored procedure and related tables see
http://www.aspfaq.com/etiquette.asp?id=5006 on how to post DDL in the news
group.
At a guess there is an insert/update statement and you are either including
the identity column or don't have SET IDENTITY_INSERT ON for the table.
John
"thomson" wrote:

> Hi All,
> i do have stored procedure
> in which there select id,name from tablename
> id i primary key and Identity seed is there for this column
>
> When i directly query this statement it " select id,name from
> tablename" , it shows the results
> But when i call the same thing via stored procedure , it says Cannot
> update identity colum
> exec usp_getvalues , it gives the error
> Thanks in Advance
> Thomson
>
|||identity columns are not updateable.
Hilary Cotter
Director of Text Mining and Database Strategy
RelevantNOISE.Com - Dedicated to mining blogs for business intelligence.
This posting is my own and doesn't necessarily represent RelevantNoise's
positions, strategies or opinions.
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"thomson" <saintthomson@.yahoo.com> wrote in message
news:1159770767.122534.31190@.h48g2000cwc.googlegro ups.com...
> Hi All,
> i do have stored procedure
> in which there select id,name from tablename
> id i primary key and Identity seed is there for this column
>
> When i directly query this statement it " select id,name from
> tablename" , it shows the results
> But when i call the same thing via stored procedure , it says Cannot
> update identity colum
> exec usp_getvalues , it gives the error
> Thanks in Advance
> Thomson
>

Cannot Update Identity Column while doing Select statement

Hi All,
i do have stored procedure
in which there select id,name from tablename
id i primary key and Identity seed is there for this column
When i directly query this statement it " select id,name from
tablename" , it shows the results
But when i call the same thing via stored procedure , it says Cannot
update identity colum
exec usp_getvalues , it gives the error
Thanks in Advance
ThomsonHi
You would not expect this error from the query you have given therefore I
suspect that your stored procedure is doing something different. Post the
code for the store stored procedure and related tables see
http://www.aspfaq.com/etiquette.asp?id=5006 on how to post DDL in the news
group.
At a guess there is an insert/update statement and you are either including
the identity column or don't have SET IDENTITY_INSERT ON for the table.
John
"thomson" wrote:
> Hi All,
> i do have stored procedure
> in which there select id,name from tablename
> id i primary key and Identity seed is there for this column
>
> When i directly query this statement it " select id,name from
> tablename" , it shows the results
> But when i call the same thing via stored procedure , it says Cannot
> update identity colum
> exec usp_getvalues , it gives the error
> Thanks in Advance
> Thomson
>|||identity columns are not updateable.
--
Hilary Cotter
Director of Text Mining and Database Strategy
RelevantNOISE.Com - Dedicated to mining blogs for business intelligence.
This posting is my own and doesn't necessarily represent RelevantNoise's
positions, strategies or opinions.
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"thomson" <saintthomson@.yahoo.com> wrote in message
news:1159770767.122534.31190@.h48g2000cwc.googlegroups.com...
> Hi All,
> i do have stored procedure
> in which there select id,name from tablename
> id i primary key and Identity seed is there for this column
>
> When i directly query this statement it " select id,name from
> tablename" , it shows the results
> But when i call the same thing via stored procedure , it says Cannot
> update identity colum
> exec usp_getvalues , it gives the error
> Thanks in Advance
> Thomson
>

Cannot Update Identity Column while doing Select statement

Hi All,
i do have stored procedure
in which there select id,name from tablename
id i primary key and Identity seed is there for this column
When i directly query this statement it " select id,name from
tablename" , it shows the results
But when i call the same thing via stored procedure , it says Cannot
update identity colum
exec usp_getvalues , it gives the error
Thanks in Advance
ThomsonHi
You would not expect this error from the query you have given therefore I
suspect that your stored procedure is doing something different. Post the
code for the store stored procedure and related tables see
http://www.aspfaq.com/etiquette.asp?id=5006 on how to post DDL in the news
group.
At a guess there is an insert/update statement and you are either including
the identity column or don't have SET IDENTITY_INSERT ON for the table.
John
"thomson" wrote:

> Hi All,
> i do have stored procedure
> in which there select id,name from tablename
> id i primary key and Identity seed is there for this column
>
> When i directly query this statement it " select id,name from
> tablename" , it shows the results
> But when i call the same thing via stored procedure , it says Cannot
> update identity colum
> exec usp_getvalues , it gives the error
> Thanks in Advance
> Thomson
>|||identity columns are not updateable.
Hilary Cotter
Director of Text Mining and Database Strategy
RelevantNOISE.Com - Dedicated to mining blogs for business intelligence.
This posting is my own and doesn't necessarily represent RelevantNoise's
positions, strategies or opinions.
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"thomson" <saintthomson@.yahoo.com> wrote in message
news:1159770767.122534.31190@.h48g2000cwc.googlegroups.com...
> Hi All,
> i do have stored procedure
> in which there select id,name from tablename
> id i primary key and Identity seed is there for this column
>
> When i directly query this statement it " select id,name from
> tablename" , it shows the results
> But when i call the same thing via stored procedure , it says Cannot
> update identity colum
> exec usp_getvalues , it gives the error
> Thanks in Advance
> Thomson
>

Cannot update ID because of no existing relationship

I have one table Phone and a table SmsMessage that are linked by the Cellnumber. Cellnumber is the primary key in Phone.

For some reason in the table Phone the Cellnumbers are stored with extra spaces like: '+27000000000 ', but in the SmsMessage table the same value is stored as '+27000000000'. However when I want perform an update to trim the Cellnumbers, I get the message 'Cannot modify values Cellnumber in Phone because there are dependent values in SmsMessage.

The fact is that there are no dependent values, but for MSSQL '+27000000000' and '+27000000000 ' is the same??! Note that the function Len(Cellnumber) gives me the length of the string WITHOUT the spaces as well.

Even if I remove all relationships from Phone, I still get the same error. Are there more places in MSSQL where relationships are stored besides the Diagrams?

Or is there a command that tells MSSQL to ignore all relationships for the next query?

Any ideas?I suspect that the data is stored in the column without the trailing spaces, although it may be presented with spaces added. This is common when retrieving data in columnar form. To test this, retrieve an expression rather than the raw column to see what you actually get, something like:SELECT myColumn, '[' + myColumn + ']'
FROM myTableThe real relationship information is stored in system tables in the form of constraints. The graphic representation is easier to understand, but the constraints are the "final answer" in terms of the relationships that MS-SQL enforces.

-PatP

Friday, February 10, 2012

cannot rename instance of analysis server.missing reg key

when i use the rename instance tool i get this error saying it cannot find the regestry key

hkey_local_Machine\wow6432Node\Microsoft\Microsoft Sql Server\90

When i look for this key, it doesnt exist. My installation went perfectly. what is going wrong

There are 2 versions of ASInstanceRename utility. Make sure you use one that is installed with 64bit version of Analysis Server.

Edward Melomed.
--
This posting is provided "AS IS" with no warranties, and confers no rights.

|||but i am using the 32 bit version of sql server 2005, and its on a 32 bit pc. theres no way i can install the 64 bit version as my machine wont even run the setup file|||

You should use 64 bit version of asinstancerename utility on 64 bit machine to rename 32bit instances. It is intended to be able to handle 32bit instances.

To get 64bit version of asinstancerename, uninstall 32bit version SQL Tools from your machine and install them back using 64ibt CD.

That should get you going.

Edward.
--
This posting is provided "AS IS" with no warranties, and confers no rights.