Failed To Decrypt Protected XML Node

Jun 27, 2007

Hi,

I,ve been searching the forum for answers to this error but with no luck:

Failed to decrypt protected XML node "DTSassword" with error 0x80070002 "The system cannot find the file specified.". You may not be authorized to access this information. This error occurs when there is a cryptographic error. Verify that the correct key is available.


Setup:
I'm running the packages from the SQL Job Agent - the packages are stored in the file system. The agent is using a proxy account to get the right permissions. I know this because the job has run for severel weeks without errors. The package is calling other packages and is using configuration files. It was actually more than on job that failed (with the same error) - but not all the jobs.

Now it is saying that it can not "find the file specified" - what file would that be? - I'm wondering if it is a package file or a configuration file or maybe another file. It dosn't give me any other information to where the problem is.

Any help is appreciated!

Regards
Simon

View 6 Replies


ADVERTISEMENT

Failed To Decrypt Protected XML Node ...

May 12, 2008



Hi All,

I am trying to run a job and when I run it I get the following error:

Description: Failed to decrypt protected XML node "PackagePassword" with error 0x8009000B "Key not valid for use in specified state.". You may not be authorized to access this information. This error occurs when there is a cryptographic error. Verify that the correct key is available. End Error Error: 2008-05-06 09:37:58.32 Code: 0xC0016016 Source: Description: Failed to decrypt protected XML node "SQLPassword" with error 0x8009000B "Key not valid for use in specified state.". You may not be authorized to access this information. This error occurs when there is a cryptographic error. Verify that the correct key is available.


I'm not sure what it means or why it is happening.

Any help would be appreciated.

Thank you.

View 2 Replies View Related

Failed To Decrypt Protected XML Node

Dec 6, 2007

Hi

I have a package that runs fine however it keeps giving me this message below. Now from a previous post it mentions it is to do with the EncriptedSensitiveWithUserKey what would be the suggestion to run it as Don't save sensitive perhaps?




Executed as user: SEA-SRV-00009SYSTEM. Microsoft (R) SQL Server Execute Package Utility Version 9.00.3042.00 for 64-bit Copyright (C) Microsoft Corp 1984-2005. All rights reserved. Started: 10:07:29 PM Error: 2007-12-05 22:07:29.78 Code: 0xC0016016 Source: Description: Failed to decrypt protected XML node "DTSassword" with error 0x8009000B "Key not valid for use in specified state.". You may not be authorized to access this information. This error occurs when there is a cryptographic error. Verify that the correct key is available. End Error DTExec: The package execution returned DTSER_SUCCESS (0). Started: 10:07:29 PM Finished: 10:07:33 PM Elapsed: 4.188 seconds. The package executed successfully. The step succeeded.

View 1 Replies View Related

Package Failed : Failed To Decrypt Protected XML Node DTS:Password With Error

Apr 21, 2008

Dear all,

I've built SSIS package and made a job to execute it automatically but it always returns an error. The job returns OK but when we looked at the Log File viewer, it conatins this error log :

Key not valid for use in specified state

Failed to decrypt protected XML node "DTS Password" with error

What's wrong with the package ?
Thanks in advance.


Best regards,

Hery

View 22 Replies View Related

Integration Services :: Failed To Decrypt Protected XML Node

Nov 21, 2005

I have developed several SSIS packages with the last Beta of VS2005 / SQL Server CTP. After the public release I tried to uninstall the CTP-Versions to install the msdn finals but this time I got lost and was not able to satisfy the requirements of the final setup of VS2005. So I decided to install the whole pc again and after some hours I had a clean machine (XP with latest SQL Server 2005 Standard and VS2005 Professional).  

Now I have tried to open my SSIS-Project but getting the following error:  

Error loading ImpNetqNewsRss.dtsx: Failed to decrypt protected XML node "DTS:Password" with error 0x8009000B "Schlüssel ist im angegebenen Status nicht gültig.". You may not be authorized to access this information. This error occurs when there is a cryptographic error. Verify that the correct key is available.

After some “googling” I found this thread: URL... If I’m right the solution should be to use a Package Password, but I can’t figure out where I have to go enter/change a password. I even can’t remember I that ever used a password on my old installation for a dtsx-package?

View 38 Replies View Related

Error Loading Package Failed To Decrypt Protected XML Node DTS

Nov 5, 2014

I get an error when trying to open an SSIS package from TFS using Visual studio 2014..

This is the error:

error loading package failed to decrypt protected xml node DTS:Password Key not valid for use in specified state you may not be authorized to view this information

This package has been developed by a person who left the company. I think he had admin permissions on the servers.

View 2 Replies View Related

Failed To Decrypt Protected XML Node DTS:Password With Error 0x8009000B

Nov 21, 2005

Hi,

View 39 Replies View Related

Failed To Decrypt Protected XML Node PackagePassword With Error 0x8009000B

Dec 28, 2006

When and why does this error message appear..

Error 1 Error loading MasterPackage.dtsx: Failed to decrypt protected XML node "PackagePassword" with error 0x8009000B "Key not valid for use in specified state.". You may not be authorized to access this information. This error occurs when there is a cryptographic error. Verify that the correct key is available.

View 6 Replies View Related

Failed To Decrypt Protected XML Node DTS:Password With Oracle As Source File

Oct 18, 2007

Hello all, I have read many topics about this error but it doesn't fix my packages in my particular case. The problem is that I access to a database in Oracle using the Ole DB provider for Oracle

I get that the mentioned error when I try to run a job from the agent.

1 - When I set "DontSaveSensitive" to ProtectionLevel I get this error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E4D.
An OLE DB record is available. Source: "Microsoft OLE DB Provider for Oracle" Hresult: 0x80040E4D Description: "ORA-01017: username/password no valid".
This is normal because the connection needs a password.


2 - When I set "EncryptSensitiveWithUserKey" to ProtectionLevel I get the mentioned error: "Failed to decrypt protected XML node "DTSassword" ..

The other options to ProtectionLevel doesn't work neither. I have tried to write the password in the field required...

I have tried many possibilities but nothing new, it doesn't work.

Does anybody have this error with Oracle as source file ???

Thank you .







View 4 Replies View Related

Execute Package Task Error: Failed To Decrypt Protected XML Node DTS:Password

Jun 20, 2006

I have a package (PackageA) with an Execute Package Task that execs PackageB. When I run PackageA I get this error on the Execute Package Task :

Failed to decrypt protected XML node "DTS:Password" with error 0x8009000B "Key not valid for use in specified state.". You may not be authorized to access this information. This error occurs when there is a cryptographic error. Verify that the correct key is available.

PackageB has 'EncryptSensitiveWithUserKey' ProtectionLevel. I'm providing passwords in the dtsConfig so I'm guessing I should change it to 'DontSaveSensitive'?

Interestingly, PackageA also has 'EncryptSensitiveWithUserKey' ProtectionLevel, but I don't get an error about PackageA, just on the task that runs PackageB.

(SP1 is installed).

View 9 Replies View Related

Integration Services :: Decrypt XML Node Failed On Loading Master Package

Dec 24, 2013

We run 2012 enterprise.  When I open my project on a different machine than the one I used to create the project,  I get the following warnings.  I'm concerned about 1) checking in source from different machines, 2) what is going to happen when we run this in production.  All of the project params are sensitive=false and required = true.  The master package stageprototype.dtproj has no pkg params and no configs. 

The project's protection level is encryptsensitivewith user key but as far as i know there is nothing sensitive in this collection of master and sub packages.  I'm concerened that id I change this to dont save sensitive, I'll be looking for a needle in a haystack, specifically the thing or things ssis thinks are sensitive right now.

Warning 1 Warning loading StagePrototype.dtproj: Warning: Failed to decrypt an encrypted XML node. Verify that the project was created by the same user. Project load will attempt to continue without the encrypted information.

 StagePrototype.dtproj 0 0
 
Warning 2 Warning loading StagePrototype.dtproj: Warning: Failed to decrypt sensitive data in project with a user key. You may not be the user who encrypted this project, or you are not using the same machine that was used to save the project. If the sensitive data is a parameter value, the value may be required to run the package on the Integration Services server.  

StagePrototype.dtproj 0 0 

View 2 Replies View Related

Need Help --&&> Connecting To Oracle Throught SSIS Package(Failed To Decrypt An Encrypted XML Node Because The Password Was Not S)

May 14, 2007

Hi,





In BI Tool SSIS Packages run fine and get data From Oracle and Save it in SQL Server.

Package Protection Level is EncryptSensitivewithPassword.

In BI tool when i open the package it ask password and then run fine.

If i change the Protection Level to Dont save Sensitive,

It does not run fine in even BI tool.


It is fine if i use EncryptSensitivewithPassword.in BI Tool and run it.

Now the problem is that i need to run this package through SQL Job.

so Job give error



"Failed to decrypt an encrypted XML node because the password was not specified or not correct. Package load will attempt to continue without the encrypted information."

Please i need help ?



Thanks

View 7 Replies View Related

Recovery :: Cluster Failover - Failed To Bring Secondary Node Online?

Oct 19, 2010

Server : Windows server 2008
DB Server : SQL Server 2008 (SP1)
 
Here are the series of events which happened.

1.) Event ID: 1135
Cluster node 'XYZ' was removed from the active failover cluster membership. The Cluster service on this node may have stopped. This could also be due to the node having lost communication with other active nodes in the failover cluster. Run the Validate a Configuration wizard to check your network configuration. If the condition persists, check for hardware or software errors related to the network adapters on this node. Also check for failures in any other network components to which the node is connected such as hubs, switches, or bridges.

2.) Event ID: 1049
Cluster IP address resource 'SQL IP Address 1 (XYZ)' cannot be brought online because a duplicate IP address '10.9.8.113' was detected on the network.  Please ensure all IP addresses are unique.

3.) Event ID: 1069
Cluster resource 'SQL IP Address 1 (XYZ)' in clustered service or application 'SQL Server (MSSQLSERVER)' failed.

4.) Event ID: 1049
Cluster IP address resource 'Cluster IP Address' cannot be brought online because a duplicate IP address '10.9.8.112' was detected on the network.  Please ensure all IP addresses are unique.

5.) Event ID: 1069
Cluster resource 'Cluster IP Address' in clustered service or application 'Cluster Group' failed.

6.) Event ID: 1066
Cluster disk resource 'Cluster Disk 25' indicates corruption for volume '?Volume{88552e6f-aea2-11df-9790-0026b92fffa7}'. Chkdsk is being run to repair problems. The disk will be unavailable until Chkdsk completes. Chkdsk output will be logged to file 'C:WindowsClusterReportsChkDsk_ResCluster Disk 25_Disk16Part1.log'. Chkdsk may also write information to the Application Event Log.

7.) Event ID : 1066
Cluster disk resource 'Cluster Disk 26' indicates corruption for volume '?Volume{88552e05-aea2-11df-9790-0026b92fffa7}'. Chkdsk is being run to repair problems. The disk will be unavailable until Chkdsk completes. Chkdsk
output will be logged to file 'C:WindowsClusterReportsChkDsk_ResCluster Disk 26_Disk4Part1.log'. Chkdsk may also write information to the Application Event Log.

8.) Event ID: 1049
  (Same message as point 2)

9.) Event ID: 1069
     (Same message as point 3)

10.) Event ID : 1049
(same message as point 4)

11.) Event ID :1069 
(same message as point 5)

12.) Event ID :1205
The Cluster service failed to bring clustered service or application 'Cluster Group' completely online or offline. One or more resources may be in a failed state. This may impact the availability of the clustered service or application.

13.) Event ID: 1069
Cluster resource 'Cluster Disk 17' in clustered service or application 'SQL Server (MSSQLSERVER)' failed.

14.) Event D : 1049
(same message as point 2)

15.) Event ID: 1069
Cluster resource 'SQL IP Address 1 (XYZ)' in clustered service or application 'SQL Server (MSSQLSERVER)' failed.

16.) Event ID : 1205
 The Cluster service failed to bring clustered service or application 'SQL Server (MSSQLSERVER)' completely online or offline. One or more resources may be in a failed state. This may impact the availability of the clustered service or application.
 
first of all,I went through all the logs, and could not find the reason for fail-over initialization. There should be some thing logged why the failover happened? secondly after failover the service was not coming online due to duplicate IP address detection.

Later when we try  to manually bring the service online from cluster management it comes online successfully. I don't understand how would duplicate IP address get resolved when we start manually.

Lastly we see few errors related to physical disk resource between failover retries, is this could be the correlated to failover error ?

View 4 Replies View Related

SQL 2012 :: Log Shipping - Reboot Secondary Node And Then Primary Node

Apr 20, 2015

I have not used log shipping before and find myself in a position where I need to reboot the secondary node and then the primary node and I don't actually need to failover.

Is there anything I need to be aware of. When rebooting the secondary node I assume the transactions will be held in the primary nodes log till the secondary comes back and just carry on once back up?

When rebooting the primary node nothing needs to be done and the log shipping will just start again once it has come back?

View 3 Replies View Related

Do I Need To Install SQL Server To Second Node In Cluster Prior To Adding The Node?

Jun 12, 2007

I read these instructions:

http://msdn2.microsoft.com/en-us/library/ms191545(SQL.90).aspx



But I'm not sure if I have to install SQL Server first on node 2, then add it to the cluster. Or does adding it to the cluster also install the software?



Thanks

View 1 Replies View Related

SQL Server Admin 2014 :: Failed To Prepare Storage For Testing On Node Server Name

Feb 23, 2015

I Run All checks for Validation cluster.I get Error On Disk Lists And Validation failed.With This error : Failed to prepare storage for testing on node "server name" The security account manager (SAM) or local security authority (LSA) server was in the wrong state to perform the security operation.

View 2 Replies View Related

Setup And Upgrade :: Cluster Installation Failed On Adding Node To Cluster

Oct 10, 2015

During the installation of Adding node to a SQL Server failover cluster(On passive node) getting error like.. The MOF compiler could not connect with the WMI server. This is either because of a semantic error such as an incompatibility with the existing WMI repository or an actual error such as the failure of the WMI server to start.We  run the below commands but didn’t get any resolution & got the same above error .
 
1<sup>st</sup> Method…

1. Open console command (Run->CMD with administrator privileges). 

2. net stop winmgmt 

3. Rename folder %windir%System32WbemRepository to other one, for backup purposes (for example _Repository). 

4. net start winmgmt

2<sup>nd</sup> Method..

1. Disable and stop the WMI service.

a) Command : - sc config winmgmt start= disabled

b. Command : -                 net stop winmgmt

2. Run the following commands.

a).  Command:  Winmgmt /salvagerepository %windir%System32wbem

b). Command:   Winmgmt /resetrepository %windir%System32wbem

3. Re-enable the WMI service

Command:          sc config winmgmt start= auto 

Last command to run after above steps

4. Command:     mofcomp "%programfiles(x86)%Microsoft SQL Server100Sharedsqlmgmproviderxpsp2up.mof"

File not found Error for above command.

View 3 Replies View Related

SQL 2012 :: Running 2 Distinct AGs On Each Node Of A Two Node Cluster?

Oct 23, 2014

I'm contemplating running two availability groups on a two node WSFC. The WSFC is setup with a file share witness (i.e. no shared storage). Can I safely run 1 AG on one primary node, and the other AG on the other node (as primary). Each AG would have replicas on the passive node. This would effectively allow both servers to be in use at the same time. In a failover event, I understand that both workloads would transfer to a single server - so the box needs to be sized appropriately.

View 1 Replies View Related

SQL 2012 :: 3 Node Cluster Runs With 2 Node Failures?

Jun 11, 2015

We are in the process of building a 3 node SQL Server Cluster (Server 2012/ SQL Server 2012), and we have configured the quorum so that all 3 nodes have a vote (no file share witness as we already have an odd number of nodes).

As I understand it, this should allow the cluster to run as long as 2 of the nodes remain online.

However, the validation report states that 2 node failures would be acceptable and, when we tested this by powering off two of the nodes, the cluster did indeed continue to run on a single node.

View 4 Replies View Related

Transfering Cluster Resources From One Node To Another Node

Aug 21, 2007



I configure Windows 2003 R2 and SQL 2005 two nodes Cluster. When I move cluster resource from one node to anther node it takes around 30 seconds to become online. So in that time if any query is running it stops responding.



So please suggest in this regard

View 2 Replies View Related

How Do You Determine The Active Node Inside A Stored Proc For An Active/passive 2-node Cluster?

Jan 16, 2008

I invoke xp_cmdshell proc from inside a stored procedure on a 2-node active/passive SQL 2005 SP2 Standard cluster. Depending on which server the xp_cmdshell gets executed on I need to pass different arguments in the shell command. I thought I could use host_name() function to get the runtime process server, however, I am finding that it's not behaving correctly. In one example I know my active node is server2, but the host_name() function is returning server1. The only thing that I could possible explain this is that the MSDTC cluster group is not always on the same active node as the SQL server group and in the case I am talking about the cluster groups are in this mode (differnet nodes). Does the xp_cmdshell get executed by the SQL active node or the MDTC active node? And what is the best way to find out which server is going to run my xp_cmdshell?

Thanks.

Edit:

Perhaps another by product of this is that if I run select host_name() from the Studio Management query window i get different results depending on which server I am running the Studio Management on. On server1 I get server1 and on server 2 I get server 2, all the while server2 is the active node. I need a different function that will always let me determine the correct server that'll be running the xp_cmdshell...

Edit 2: I guess I could determine the running host inside the command shell itself, but I am curious to see if i can do it (cleaner) from SQL.

View 1 Replies View Related

1 Node Of Active/Active Failed

Oct 24, 2007

Hi

I have an active/active cluster and the second node failed and could not start all the instances are intact on the first node. Now we have built the second node and joined to the cluster group as well.

I am sure we dont need a install as all the instances are there so anyone know where I need to join the SQL cluster to talk to both the nodes

Thanks in advance

Anup

View 1 Replies View Related

Database Password Protected

Sep 7, 2013

how to make my sqlserver 2005 database password protected.i make a database and i want to make a password protected.

View 4 Replies View Related

Protected Sql Database File

Jan 11, 2007

how can I create sql database file and it cann't be use or open (open mean to design view or structure) .

my case is: I have Acces db and this db has its own username and password, no body can read, write or view the designing, so it is useless. But there are somesoftware able to break and hacking db access. I think sql database file is more secure, so how can I do it?

View 10 Replies View Related

Is My SQL Server DB Protected From Hosting People?

Mar 15, 2004

Hi Friends,

If I upload my Sql Server Database to a hosting company, can they see my tables?

Regards,

View 1 Replies View Related

Import Password Protected File Via DTS

Jul 23, 2005

I am trying to import a password-protected Excel file into SQL Serverusing DTS. I am getting an error that it can't decrypt file. Doesanyone know how I can pass the password to the file during the DTSexecution. Please help.Thanks,Michelle

View 1 Replies View Related

Can A View Be Protected To Support JOINS Only?

Oct 10, 2007

I know this is a way-out question, and I'm not confident of a positiveanswer, but I'd like to know whether it is possible to protect/secure a Viewso that it can only be used as a TARGET in a join operation, as opposed tobeing used for direct SELECT.for example:SELECT * FROM MyView -- would failbutSELECT * FROM Customer cLEFT OUTER JOIN MyView v ( on v.Key = c.ViewKey ) -- would succeedThe question is predicated on an idea that sometimes data is permissable toaccess when presenting it as "secondary data" because we are accessingindividual "points" of data, but we don't want people accessing the entiredata-set.I know that the JOINed query above could be made into another View, bypassMyView altogether (simply reference the underlying table), in which caseMyView becomes superfluous and the desired outcome is achieved.Except that: depending on the combinations of JOINS, and if there aremultiple of them, I might end up with a large number of views to allow forall the combinations of different joins that I want. For example, a tablewith 6 foreign keys has 64 different combinations to cover the differentjoins I might or might not want to make. A table with 10 foreign keys takesthat up to 1024 combinations etc.

View 1 Replies View Related

Executing Password Protected Packages

Apr 13, 2006

Hi - I have a master package that executes a series of other packages. Each of these 'sub' packages has the security property Encryption Level set to 'EncryptSensitiveWithPassword'.

The master package has a series of file connections in the Connection Manager, one for each sub package, in which the password of the corresponding sub package is provided.

When I run the master package in BIDS (in interactive mode) it opens each of the sub packages, requests the password and gives the 'Document contains one or more lines of extremely long text' dialog box.

Is there any way to suppress the repeated password requests (seeing as it has already been provided in the Connection Manager) and warnings about long lines of text when executing the master package?

Thanks . . . Ed

View 6 Replies View Related

Removing Protected Beta Files

Oct 1, 2006

I cannot install SQL SErver 2005 because of files still on my hard disk from beta version. These include sqlmgmprovider.dll and svrenumapi.dll. The uninstall program is no longer available. How do I get rid of whatever remains of the old beta installation so that the released version of SQL Server 2005 will install?

View 9 Replies View Related

Error Reading Password-protected FM In SQL Server

Jul 28, 2006

I'm trying to pull certain Filemaker 5 tables into SQL Server 2000 inan automated import job using a file DSN. Everything resides locallyon a Windows XP machine. My process works fine on a test FM file withno password, but with the real FM files, all password protected, itfails with this error:******Error Source: Microsoft OLE DB Provider for ODBC DriversError Description: Unspecified error[FileMaker][ODBC FileMaker Pro driver]An error has occurred whiletrying to gather a list of available tables.[FileMaker][ODBC FileMaker Pro driver][FileMaker Pro]Connect failed.Context: Error calling GetRowSet to get DBSCHEMA_TABLES schema info.Your provider does not support all the schema rowsets required by DTS.******This happens whether or not I supply a password to the SQL Server job.It has been nagging me for days and I can't find any documentation onit. Has anyone else encountered this?Thanks very much.Scott

View 1 Replies View Related

Attempted To Read Or Write Protected Memory

Nov 23, 2005

One of the packages we've created a while ago is now, suddenly, giving us a strange error:

View 3 Replies View Related

Sensitive Info Protected With Password - Best Practices

Oct 4, 2006

I have been selecting the option to protect sensitive info in my packages with a password. However, this poses problems when later execute the packages by using the Execute Package Task. The problem is that I am repeated required to input the password before the packages will execute.

I was making this selection in the hope of not tying execution to a partiular user's credentials (my boss may also want to execute these pacakages at some point).

I find this subject confusing. Once I have selected this option, how can I change to another method? Additionally, does anyone have any advice vis a vis best practices in this matter? I want to store connection passwords, etc. in the package so they don't have to be supplied each time but I also want the information to be secure.

Thanks in advance for any information.



View 1 Replies View Related

Schema-protected Multi Client Database

Jan 4, 2007

I am currently building an application that will host multiple clients in the same database. Each client will have their own schema. Common data will be stored in [dbo] tables commonly accessible. Client data will be stored in matching schema-specific tables.
EX:

[ClientA].[Orders] ...
[ClientB].[Orders] ...
[ClientC].[Orders] ...


So far so good.
Upon issuing select statements under the various logins, the proper table is accessed and improper tables are protected.

The problem comes when working with the various stored procs to access the data.
My original though was that I would have one version of the stored procs and they would be calling-schema aware, much like select statements are, and deal with the proper table data. What seems to be the case is that each client needs its own copy of ALL the stored procs, creating a maintenance nightmare considering each client's procs is identical in EVERY SINGLE WAY except for the owning schema.

It seems once a proc is called the ownership chain changes to the proc's schema and ignores the caller from there on out. Am I missing a step in this or do I have the proper understanding (and problem).

Example:

Attached is a sample database script.
Four (matching) tables. Stored proc for accessing data via a table function. Three logins dealing with various iterations:

login: clienta
setup: Entry point proc set, table function missing (will call dbo version)
result: Permission error on call to table function. Fix that and pulls data from dbo table

login: clientb

setup: Entry point proc using dbo, schema-specific table function set

result: Calls dbo version of function (not schema version) and pulls dbo table data

login: clientc

setup: Entry point proc set, table function set

result: Correct data pulled from schema table


login: db owner login

setup: Both dbo proc and dbo function set

result: DBO table data pulled


======================================================

-- ====================================================================
--
-- Create Database SchemaTest
--
-- ====================================================================

CREATE DATABASE SchemaTest
GO
USE SchemaTest
GO

-- ====================================================================
--
-- Create Users and Schemas
--
-- ====================================================================

IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'clienta')
CREATE USER [clienta] FOR LOGIN [clienta] WITH DEFAULT_SCHEMA=[ClientA]
GO
IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'clientb')
CREATE USER [clientb] FOR LOGIN [clientb] WITH DEFAULT_SCHEMA=[ClientB]
GO
IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'clientc')
CREATE USER [clientc] FOR LOGIN [clientc] WITH DEFAULT_SCHEMA=[ClientC]
GO


IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = N'ClientA')
EXEC sys.sp_executesql N'CREATE SCHEMA [ClientA] AUTHORIZATION [clienta]'
GO

IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = N'ClientB')
EXEC sys.sp_executesql N'CREATE SCHEMA [ClientB] AUTHORIZATION [dbo]'
GO


IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = N'ClientC')
EXEC sys.sp_executesql N'CREATE SCHEMA [ClientC] AUTHORIZATION [dbo]'
GO






-- ====================================================================
--
-- Create Tables SType for each Schema
--
-- ====================================================================


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ClientA].[SType]') AND type in (N'U'))
BEGIN
CREATE TABLE [ClientA].[SType](
[TypeID] [int] IDENTITY(1,1) NOT NULL,
[Text] [varchar](50) NOT NULL,
[Description] [varchar](100) NULL,
CONSTRAINT [PK_Type] PRIMARY KEY CLUSTERED
(
[TypeID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ClientB].[SType]') AND type in (N'U'))
BEGIN
CREATE TABLE [ClientB].[SType](
[TypeID] [int] IDENTITY(1,1) NOT NULL,
[Text] [varchar](50) NOT NULL,
[Description] [varchar](100) NULL,
CONSTRAINT [PK_Type] PRIMARY KEY CLUSTERED
(
[TypeID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ClientC].[SType]') AND type in (N'U'))
BEGIN
CREATE TABLE [ClientC].[SType](
[TypeID] [int] IDENTITY(1,1) NOT NULL,
[Text] [varchar](50) NOT NULL,
[Description] [varchar](100) NULL,
CONSTRAINT [PK_Type] PRIMARY KEY CLUSTERED
(
[TypeID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SType]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SType](
[TypeID] [int] IDENTITY(1,1) NOT NULL,
[Text] [varchar](50) NOT NULL,
[Description] [varchar](100) NULL,
CONSTRAINT [PK_Type] PRIMARY KEY CLUSTERED
(
[TypeID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

-- ========================================================
-- Insert Sample Data
--
-- ========================================================
INSERT INTO [ClientA].[SType]
([Text])
VALUES ('A Data')

INSERT INTO [ClientB].[SType]
([Text])
VALUES ('B Data')

INSERT INTO [ClientC].[SType]
([Text])
VALUES ('C Data')

INSERT INTO [dbo].[SType]
([Text])
VALUES ('dbo Master Data')

GO







-- ====================================================================
--
-- Create proc GimmeTable for each Schema
--
-- ClientA has version
-- ClientB does not have version (will use dbo version)
-- ClientC has version
--
-- ====================================================================

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GimmeTable]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[GimmeTable]
AS
BEGIN
SELECT * from tableSType()
END

'
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ClientA].[GimmeTable]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE [ClientA].[GimmeTable]
AS
BEGIN
SELECT * from tableSType()
END

'
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ClientC].[GimmeTable]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
create PROCEDURE [ClientC].[GimmeTable]
AS
BEGIN
SELECT * from tableSType()
END


'
END
GO


-- ====================================================================
--
-- Create table function tableSType() for each Schema
--
-- ClientA does not have version (will use dbo version)
-- ClientB has version
-- ClientC has version
--
-- ====================================================================

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ClientB].[tableSType]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
BEGIN
execute dbo.sp_executesql @statement = N'-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE FUNCTION [ClientB].[tableSType]
()
RETURNS TABLE
AS
RETURN
(
select * from SType
)
'
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ClientC].[tableSType]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
BEGIN
execute dbo.sp_executesql @statement = N'-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE FUNCTION [ClientC].[tableSType]
()
RETURNS TABLE
AS
RETURN
(
select * from SType
)
'
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tableSType]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
BEGIN
execute dbo.sp_executesql @statement = N'-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
create FUNCTION [dbo].[tableSType]
()
RETURNS TABLE
AS
RETURN
(
select * from SType
)

'
END




-- ====================================================================
--
-- Set permissions on GimmeTable to public
--
-- ====================================================================

GRANT EXEC ON [dbo].[GimmeTable] TO PUBLIC
GRANT EXEC ON [ClientA].[GimmeTable] TO PUBLIC
GRANT EXEC ON [ClientC].[GimmeTable] TO PUBLIC

GRANT SELECT ON [dbo].[SType] TO PUBLIC
GRANT SELECT ON [ClientA].[SType] TO PUBLIC
GRANT SELECT ON [ClientB].[SType] TO PUBLIC
GRANT SELECT ON [ClientC].[SType] TO PUBLIC

GO






-- ====================================================================
--
-- Use these statements with each user and compare results
--
-- ====================================================================


EXEC GimmeTable
select * from SType

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved