CREATE PROCEDURE [dbo].[AddDataSource]
@DSID [uniqueidentifier],
@ItemID [uniqueidentifier] = NULL,
@SubscriptionID [uniqueidentifier] = NULL,
@Name [nvarchar] (260) = NULL,
@Extension [nvarchar] (260) = NULL,
@LinkID [uniqueidentifier] = NULL,
@LinkPath [nvarchar] (425) = NULL,
@CredentialRetrieval [int],
@Prompt [ntext] = NULL,
@ConnectionString [image] = NULL,
@OriginalConnectionString [image] = NULL,
@OriginalConnectStringExpressionBased [bit] = NULL,
@UserName [image] = NULL,
@Password [image] = NULL,
@Flags [int],
@AuthType [int],
@Version [int]
AS
DECLARE @ActualLinkID uniqueidentifier
SET @ActualLinkID = NULL
IF (@LinkID is NULL) AND (@LinkPath is not NULL) BEGIN
SELECT
Type, ItemID, NtSecDescPrimary
FROM
Catalog LEFT OUTER JOIN SecData ON Catalog.PolicyID = SecData.PolicyID AND SecData.AuthType = @AuthType
WHERE
Path = @LinkPath
SET @ActualLinkID = (SELECT ItemID FROM Catalog WHERE Path = @LinkPath)
END
ELSE BEGIN
SET @ActualLinkID = @LinkID
END
INSERT
INTO DataSource
([DSID], [ItemID], [SubscriptionID], [Name], [Extension], [Link],
[CredentialRetrieval], [Prompt],
[ConnectionString], [OriginalConnectionString], [OriginalConnectStringExpressionBased],
[UserName], [Password], [Flags], [Version])
VALUES
(@DSID, @ItemID, @SubscriptionID, @Name, @Extension, @ActualLinkID,
@CredentialRetrieval, @Prompt,
@ConnectionString, @OriginalConnectionString, @OriginalConnectStringExpressionBased,
@UserName, @Password, @Flags, @Version)
GO
GRANT EXECUTE ON [dbo].[AddDataSource] TO [RSExecRole]
GO