Showing posts with label bol. Show all posts
Showing posts with label bol. Show all posts

Monday, March 19, 2012

DecryptByKeyAutoCert with cert_password bugged?

I am having trouble with the DecryptByKeyAutoCert function when I try to provide the cert_password parameter.

According to the BOL, it is the second parameter of the function:
DecryptByKeyAutoCert
( cert_ID , cert_password , { 'ciphertext' | @.ciphertext }
[ , { add_authenticator | @.add_authenticator }
[ , { authenticator | @.authenticator } ]
]
)
However, when I provide a password, I get the following error:
Msg 8116, Level 16, State 1, Line 1
Argument data type varchar is invalid for argument 2 of DecryptByKeyAutoCert function.

This is totally in contradiction with what the BOL description says:

cert_password

Is the password that protects the private key of the certificate. Can be NULL if the private key is protected by the database master key. varchar.

Does anyone have any experience with this? I tried Google already but didn't get too many results, unfortunately.

I do not want to use the master key because that would enable all DBAs to read the encrypted data without knowing any password to decrypt. But I do need to use the automatic function due to the design of our dated VB6 application (i.e. it is impossible to open the key prior to the select due to design of interaction with Crystal Reports).

Also, is there any way to find out what parameter type the function is actually expecting? Where are these functions stored?

PS: I tried this on win2003 SP1/SQL2005 SP1 and winXP SP2/SQL2005 SP2 - same result on both.

Thanks in advance!

Okay, I found the solution: the function apparently expects an nvarchar instead of a varchar...
What a difference one letter sometimes can make...

Decrypt permissions?

Howdy all. I just did the BOL example of encrypting a column of data:
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/38e9bf58-10c6-46ed-83cb-e2d7
6cda0adc.htm
and it worked great. However, Ive been trying to figure out how to let an
end user (someone with just read permissions) decrypt the data for a while
now to no avail. Can someone please assist? Also, I had to use "
WITH ALGORITHM = DES"
instead of what BOL said to to my version of SQL Server.
TIA, ChrisRChrisR wrote:
> Howdy all. I just did the BOL example of encrypting a column of data:
> ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/38e9bf58-10c6-46ed-83cb-e2d7
> 6cda0adc.htm
> and it worked great. However, Ive been trying to figure out how to let an
> end user (someone with just read permissions) decrypt the data for a while
> now to no avail. Can someone please assist? Also, I had to use "
> WITH ALGORITHM = DES"
> instead of what BOL said to to my version of SQL Server.
> TIA, ChrisR
The end user can access the data through a stored proc that decrypts
the data for him. Stored procs are the preferred method for data access
whether or not the data is encrypted. Execute permission is all that
the user will need.
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||Thank you David. Do you happen to know if it can be done without an SP or
not? We replicate a lot of data to a "reporting box", with the sole purpose
in mind of developers and power users being able to query their own data.
Thanks again.
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:1164063291.160874.187260@.b28g2000cwb.googlegroups.com...
> ChrisR wrote:
> > Howdy all. I just did the BOL example of encrypting a column of data:
> >
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/38e9bf58-10c6-46ed-83cb-e2d7
> > 6cda0adc.htm
> >
> > and it worked great. However, Ive been trying to figure out how to let
an
> > end user (someone with just read permissions) decrypt the data for a
while
> > now to no avail. Can someone please assist? Also, I had to use "
> > WITH ALGORITHM = DES"
> >
> > instead of what BOL said to to my version of SQL Server.
> >
> > TIA, ChrisR
> The end user can access the data through a stored proc that decrypts
> the data for him. Stored procs are the preferred method for data access
> whether or not the data is encrypted. Execute permission is all that
> the user will need.
> --
> David Portas, SQL Server MVP
> Whenever possible please post enough code to reproduce your problem.
> Including CREATE TABLE and INSERT statements usually helps.
> State what version of SQL Server you are using and specify the content
> of any error messages.
> SQL Server Books Online:
> http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
> --
>|||The whole ide of using an SP is to provide access to the data without
granting permissions to the base table. Can you avoid using an SP? Sure but
that means you will end up providing access to the encryption key and table
which is usually not a good thing to do if you are really concerned about
security.
You could tweak the SP to have parameter for the calling userID (assuming
you have some way to determine the rows for "permitted" users) and filter
the results with a where clause but that can be a sizeable perf hit if
you're dealing with large tables and/or many concurrent users. If they don't
mind since it's a reporting server, lucky you.
joe.
"ChrisR" <noFudgingWay@.NoEmail.com> wrote in message
news:OVIC2SRDHHA.4832@.TK2MSFTNGP06.phx.gbl...
> Thank you David. Do you happen to know if it can be done without an SP or
> not? We replicate a lot of data to a "reporting box", with the sole
> purpose
> in mind of developers and power users being able to query their own data.
> Thanks again.
>
> "David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
> news:1164063291.160874.187260@.b28g2000cwb.googlegroups.com...
>> ChrisR wrote:
>> > Howdy all. I just did the BOL example of encrypting a column of data:
>> >
> ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/38e9bf58-10c6-46ed-83cb-e2d7
>> > 6cda0adc.htm
>> >
>> > and it worked great. However, Ive been trying to figure out how to let
> an
>> > end user (someone with just read permissions) decrypt the data for a
> while
>> > now to no avail. Can someone please assist? Also, I had to use "
>> > WITH ALGORITHM = DES"
>> >
>> > instead of what BOL said to to my version of SQL Server.
>> >
>> > TIA, ChrisR
>> The end user can access the data through a stored proc that decrypts
>> the data for him. Stored procs are the preferred method for data access
>> whether or not the data is encrypted. Execute permission is all that
>> the user will need.
>> --
>> David Portas, SQL Server MVP
>> Whenever possible please post enough code to reproduce your problem.
>> Including CREATE TABLE and INSERT statements usually helps.
>> State what version of SQL Server you are using and specify the content
>> of any error messages.
>> SQL Server Books Online:
>> http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
>> --
>|||Thanks Joe. I understand the importance of security, but (unfortunately) the
powers that be want to be able to directly query their data. You brought up
a good point though that I hadn't thought of, passing out the encryption key
is a strong arguement, and won I can probably win.
Thanks!
"Joe Yong" <NO_jyong@.SPAM_scalabilityexperts.com> wrote in message
news:excTblRDHHA.4404@.TK2MSFTNGP03.phx.gbl...
> The whole ide of using an SP is to provide access to the data without
> granting permissions to the base table. Can you avoid using an SP? Sure
but
> that means you will end up providing access to the encryption key and
table
> which is usually not a good thing to do if you are really concerned about
> security.
> You could tweak the SP to have parameter for the calling userID (assuming
> you have some way to determine the rows for "permitted" users) and filter
> the results with a where clause but that can be a sizeable perf hit if
> you're dealing with large tables and/or many concurrent users. If they
don't
> mind since it's a reporting server, lucky you.
>
> joe.
> "ChrisR" <noFudgingWay@.NoEmail.com> wrote in message
> news:OVIC2SRDHHA.4832@.TK2MSFTNGP06.phx.gbl...
> > Thank you David. Do you happen to know if it can be done without an SP
or
> > not? We replicate a lot of data to a "reporting box", with the sole
> > purpose
> > in mind of developers and power users being able to query their own
data.
> >
> > Thanks again.
> >
> >
> > "David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
> > news:1164063291.160874.187260@.b28g2000cwb.googlegroups.com...
> >> ChrisR wrote:
> >> > Howdy all. I just did the BOL example of encrypting a column of data:
> >> >
> >
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/38e9bf58-10c6-46ed-83cb-e2d7
> >> > 6cda0adc.htm
> >> >
> >> > and it worked great. However, Ive been trying to figure out how to
let
> > an
> >> > end user (someone with just read permissions) decrypt the data for a
> > while
> >> > now to no avail. Can someone please assist? Also, I had to use "
> >> > WITH ALGORITHM = DES"
> >> >
> >> > instead of what BOL said to to my version of SQL Server.
> >> >
> >> > TIA, ChrisR
> >>
> >> The end user can access the data through a stored proc that decrypts
> >> the data for him. Stored procs are the preferred method for data access
> >> whether or not the data is encrypted. Execute permission is all that
> >> the user will need.
> >>
> >> --
> >> David Portas, SQL Server MVP
> >>
> >> Whenever possible please post enough code to reproduce your problem.
> >> Including CREATE TABLE and INSERT statements usually helps.
> >> State what version of SQL Server you are using and specify the content
> >> of any error messages.
> >>
> >> SQL Server Books Online:
> >> http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
> >> --
> >>
> >
> >
>|||Windows 200 Pro SP4.
SQL 2005 SP1.
I can get the decryption to work as me, but if I open up a new connection
with my test user, it returns NULL values instead of the decrypted data.
This is even if I create a proc and grant exec rights to the test user. Here
is precisely what I did:
USE AdventureWorks;
GO
--If there is no master key, create one now
IF NOT EXISTS
(SELECT * FROM sys.symmetric_keys WHERE symmetric_key_id = 101)
CREATE MASTER KEY ENCRYPTION BY
PASSWORD ='23987hxJKL95QYV4369#ghf0%94467GRdkjuw54ie5y01478dDkjdahflkujaslekjg5k3fd117
r$$#1946kcj$n44ncjhdlj'
GO
CREATE CERTIFICATE HumanResources037
WITH SUBJECT = 'Employee Social Security Numbers';
GO
CREATE SYMMETRIC KEY SSN_Key_01
WITH ALGORITHM = DES
ENCRYPTION BY CERTIFICATE HumanResources037;
GO
USE [AdventureWorks];
GO
-- Create a column in which to store the encrypted data
ALTER TABLE HumanResources.Employee
ADD EncryptedNationalIDNumber varbinary(128);
GO
-- Open the symmetric key with which to encrypt the data
OPEN SYMMETRIC KEY SSN_Key_01
DECRYPTION BY CERTIFICATE HumanResources037;
-- Encrypt the value in column NationalIDNumber with symmetric
-- key SSN_Key_01. Save the result in column EncryptedNationalIDNumber.
UPDATE HumanResources.Employee
SET EncryptedNationalIDNumber = EncryptByKey(Key_GUID('SSN_Key_01'),
NationalIDNumber);
GO
-- Verify the encryption.
-- First, open the symmetric key with which to decrypt the data
OPEN SYMMETRIC KEY SSN_Key_01
DECRYPTION BY CERTIFICATE HumanResources037;
GO
-- Now list the original ID, the encrypted ID, and the
-- decrypted ciphertext. If the decryption worked, the original
-- and the decrypted ID will match.
create procedure getDecryptedIDNumber
as
SELECT NationalIDNumber, EncryptedNationalIDNumber
AS "Encrypted ID Number",
CONVERT(nvarchar, DecryptByKey(EncryptedNationalIDNumber))
AS "Decrypted ID Number"
FROM HumanResources.Employee;
GO
/*works for me*/
exec getDecryptedIDNumber
USE [master]
GO
CREATE LOGIN [test] WITH PASSWORD=N'test',
DEFAULT_DATABASE=[AdventureWorks], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
GO
USE [AdventureWorks]
GO
CREATE USER [test] FOR LOGIN [test]
GO
use [AdventureWorks]
GO
GRANT EXECUTE ON [dbo].[getDecryptedIDNumber] TO [test]
GO
/*Now, open up a "file/new/DB Engine Query" and login with the test login*/
exec getDecryptedIDNumber
/*This returns NULL values where it should show the decrypted data*/
Can someone please assist?
TIA, ChrisR|||You're missing the "EXECUTE AS OWNER" or execute as something-or-other
clause in your create procedure statement. If you don't have that clause, it
will default to execute as caller which means any user executing that sproc
will be checked for permissions and if it isn't granted, you get null values
in your SELECT.
joe.
"ChrisR" <noFudgingWay@.NoEmail.com> wrote in message
news:ONry7jYDHHA.3524@.TK2MSFTNGP06.phx.gbl...
> Windows 200 Pro SP4.
> SQL 2005 SP1.
> I can get the decryption to work as me, but if I open up a new connection
> with my test user, it returns NULL values instead of the decrypted data.
> This is even if I create a proc and grant exec rights to the test user.
> Here
> is precisely what I did:
>
> USE AdventureWorks;
> GO
>
> --If there is no master key, create one now
> IF NOT EXISTS
> (SELECT * FROM sys.symmetric_keys WHERE symmetric_key_id = 101)
> CREATE MASTER KEY ENCRYPTION BY
> PASSWORD => '23987hxJKL95QYV4369#ghf0%94467GRdkjuw54ie5y01478dDkjdahflkujaslekjg5k3fd117
> r$$#1946kcj$n44ncjhdlj'
> GO
>
> CREATE CERTIFICATE HumanResources037
> WITH SUBJECT = 'Employee Social Security Numbers';
> GO
>
> CREATE SYMMETRIC KEY SSN_Key_01
> WITH ALGORITHM = DES
> ENCRYPTION BY CERTIFICATE HumanResources037;
> GO
>
> USE [AdventureWorks];
> GO
>
> -- Create a column in which to store the encrypted data
> ALTER TABLE HumanResources.Employee
> ADD EncryptedNationalIDNumber varbinary(128);
> GO
>
> -- Open the symmetric key with which to encrypt the data
> OPEN SYMMETRIC KEY SSN_Key_01
> DECRYPTION BY CERTIFICATE HumanResources037;
>
> -- Encrypt the value in column NationalIDNumber with symmetric
> -- key SSN_Key_01. Save the result in column EncryptedNationalIDNumber.
> UPDATE HumanResources.Employee
> SET EncryptedNationalIDNumber = EncryptByKey(Key_GUID('SSN_Key_01'),
> NationalIDNumber);
> GO
>
> -- Verify the encryption.
> -- First, open the symmetric key with which to decrypt the data
> OPEN SYMMETRIC KEY SSN_Key_01
> DECRYPTION BY CERTIFICATE HumanResources037;
> GO
>
> -- Now list the original ID, the encrypted ID, and the
> -- decrypted ciphertext. If the decryption worked, the original
> -- and the decrypted ID will match.
> create procedure getDecryptedIDNumber
> as
> SELECT NationalIDNumber, EncryptedNationalIDNumber
> AS "Encrypted ID Number",
> CONVERT(nvarchar, DecryptByKey(EncryptedNationalIDNumber))
> AS "Decrypted ID Number"
> FROM HumanResources.Employee;
> GO
>
> /*works for me*/
> exec getDecryptedIDNumber
>
> USE [master]
> GO
> CREATE LOGIN [test] WITH PASSWORD=N'test',
> DEFAULT_DATABASE=[AdventureWorks], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
> GO
> USE [AdventureWorks]
> GO
> CREATE USER [test] FOR LOGIN [test]
> GO
>
> use [AdventureWorks]
> GO
> GRANT EXECUTE ON [dbo].[getDecryptedIDNumber] TO [test]
> GO
>
> /*Now, open up a "file/new/DB Engine Query" and login with the test
> login*/
>
> exec getDecryptedIDNumber
>
> /*This returns NULL values where it should show the decrypted data*/
>
> Can someone please assist?
>
> TIA, ChrisR
>
>|||Thanks Joe, but I just tried:
ALTER procedure [dbo].[getDecryptedIDNumber]
with execute as 'dbo'
as
SELECT NationalIDNumber, EncryptedNationalIDNumber
AS "Encrypted ID Number",
CONVERT(nvarchar, DecryptByKey(EncryptedNationalIDNumber))
AS "Decrypted ID Number"
FROM HumanResources.Employee;
use [AdventureWorks]
GO
GRANT IMPERSONATE ON USER::[dbo] TO [test]
GO
exec as user = 'dbo'
exec getDecryptedIDNumber
and it still comes back as NULL. Any other ideas?
"Joe Yong" <NO_jyong@.SPAM_scalabilityexperts.com> wrote in message
news:ONp1UqeDHHA.1196@.TK2MSFTNGP02.phx.gbl...
> You're missing the "EXECUTE AS OWNER" or execute as something-or-other
> clause in your create procedure statement. If you don't have that clause,
it
> will default to execute as caller which means any user executing that
sproc
> will be checked for permissions and if it isn't granted, you get null
values
> in your SELECT.
>
> joe.
>
> "ChrisR" <noFudgingWay@.NoEmail.com> wrote in message
> news:ONry7jYDHHA.3524@.TK2MSFTNGP06.phx.gbl...
> > Windows 200 Pro SP4.
> > SQL 2005 SP1.
> >
> > I can get the decryption to work as me, but if I open up a new
connection
> > with my test user, it returns NULL values instead of the decrypted data.
> > This is even if I create a proc and grant exec rights to the test user.
> > Here
> > is precisely what I did:
> >
> >
> > USE AdventureWorks;
> >
> > GO
> >
> >
> >
> > --If there is no master key, create one now
> >
> > IF NOT EXISTS
> >
> > (SELECT * FROM sys.symmetric_keys WHERE symmetric_key_id = 101)
> >
> > CREATE MASTER KEY ENCRYPTION BY
> >
> > PASSWORD => >
'23987hxJKL95QYV4369#ghf0%94467GRdkjuw54ie5y01478dDkjdahflkujaslekjg5k3fd117
> > r$$#1946kcj$n44ncjhdlj'
> >
> > GO
> >
> >
> >
> > CREATE CERTIFICATE HumanResources037
> >
> > WITH SUBJECT = 'Employee Social Security Numbers';
> >
> > GO
> >
> >
> >
> > CREATE SYMMETRIC KEY SSN_Key_01
> >
> > WITH ALGORITHM = DES
> >
> > ENCRYPTION BY CERTIFICATE HumanResources037;
> >
> > GO
> >
> >
> >
> > USE [AdventureWorks];
> >
> > GO
> >
> >
> >
> > -- Create a column in which to store the encrypted data
> >
> > ALTER TABLE HumanResources.Employee
> >
> > ADD EncryptedNationalIDNumber varbinary(128);
> >
> > GO
> >
> >
> >
> > -- Open the symmetric key with which to encrypt the data
> >
> > OPEN SYMMETRIC KEY SSN_Key_01
> >
> > DECRYPTION BY CERTIFICATE HumanResources037;
> >
> >
> >
> > -- Encrypt the value in column NationalIDNumber with symmetric
> >
> > -- key SSN_Key_01. Save the result in column EncryptedNationalIDNumber.
> >
> > UPDATE HumanResources.Employee
> >
> > SET EncryptedNationalIDNumber = EncryptByKey(Key_GUID('SSN_Key_01'),
> > NationalIDNumber);
> >
> > GO
> >
> >
> >
> > -- Verify the encryption.
> >
> > -- First, open the symmetric key with which to decrypt the data
> >
> > OPEN SYMMETRIC KEY SSN_Key_01
> >
> > DECRYPTION BY CERTIFICATE HumanResources037;
> >
> > GO
> >
> >
> >
> > -- Now list the original ID, the encrypted ID, and the
> >
> > -- decrypted ciphertext. If the decryption worked, the original
> >
> > -- and the decrypted ID will match.
> >
> > create procedure getDecryptedIDNumber
> >
> > as
> >
> > SELECT NationalIDNumber, EncryptedNationalIDNumber
> >
> > AS "Encrypted ID Number",
> >
> > CONVERT(nvarchar, DecryptByKey(EncryptedNationalIDNumber))
> >
> > AS "Decrypted ID Number"
> >
> > FROM HumanResources.Employee;
> >
> > GO
> >
> >
> >
> > /*works for me*/
> >
> > exec getDecryptedIDNumber
> >
> >
> >
> > USE [master]
> >
> > GO
> >
> > CREATE LOGIN [test] WITH PASSWORD=N'test',
> > DEFAULT_DATABASE=[AdventureWorks], CHECK_EXPIRATION=OFF,
CHECK_POLICY=OFF
> >
> > GO
> >
> > USE [AdventureWorks]
> >
> > GO
> >
> > CREATE USER [test] FOR LOGIN [test]
> >
> > GO
> >
> >
> >
> > use [AdventureWorks]
> >
> > GO
> >
> > GRANT EXECUTE ON [dbo].[getDecryptedIDNumber] TO [test]
> >
> > GO
> >
> >
> >
> > /*Now, open up a "file/new/DB Engine Query" and login with the test
> > login*/
> >
> >
> >
> > exec getDecryptedIDNumber
> >
> >
> >
> > /*This returns NULL values where it should show the decrypted data*/
> >
> >
> >
> > Can someone please assist?
> >
> >
> >
> > TIA, ChrisR
> >
> >
> >
>

Decrypt permissions?

Howdy all. I just did the BOL example of encrypting a column of data:
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/38e9bf58-10c6-46ed-83cb-e2d7
6cda0adc.htm
and it worked great. However, Ive been trying to figure out how to let an
end user (someone with just read permissions) decrypt the data for a while
now to no avail. Can someone please assist? Also, I had to use "
WITH ALGORITHM = DES"
instead of what BOL said to to my version of SQL Server.
TIA, ChrisR
ChrisR wrote:
> Howdy all. I just did the BOL example of encrypting a column of data:
> ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/38e9bf58-10c6-46ed-83cb-e2d7
> 6cda0adc.htm
> and it worked great. However, Ive been trying to figure out how to let an
> end user (someone with just read permissions) decrypt the data for a while
> now to no avail. Can someone please assist? Also, I had to use "
> WITH ALGORITHM = DES"
> instead of what BOL said to to my version of SQL Server.
> TIA, ChrisR
The end user can access the data through a stored proc that decrypts
the data for him. Stored procs are the preferred method for data access
whether or not the data is encrypted. Execute permission is all that
the user will need.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
|||Thank you David. Do you happen to know if it can be done without an SP or
not? We replicate a lot of data to a "reporting box", with the sole purpose
in mind of developers and power users being able to query their own data.
Thanks again.
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:1164063291.160874.187260@.b28g2000cwb.googlegr oups.com...[vbcol=seagreen]
> ChrisR wrote:
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/38e9bf58-10c6-46ed-83cb-e2d7[vbcol=seagreen]
an[vbcol=seagreen]
while
> The end user can access the data through a stored proc that decrypts
> the data for him. Stored procs are the preferred method for data access
> whether or not the data is encrypted. Execute permission is all that
> the user will need.
> --
> David Portas, SQL Server MVP
> Whenever possible please post enough code to reproduce your problem.
> Including CREATE TABLE and INSERT statements usually helps.
> State what version of SQL Server you are using and specify the content
> of any error messages.
> SQL Server Books Online:
> http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
> --
>
|||The whole ide of using an SP is to provide access to the data without
granting permissions to the base table. Can you avoid using an SP? Sure but
that means you will end up providing access to the encryption key and table
which is usually not a good thing to do if you are really concerned about
security.
You could tweak the SP to have parameter for the calling userID (assuming
you have some way to determine the rows for "permitted" users) and filter
the results with a where clause but that can be a sizeable perf hit if
you're dealing with large tables and/or many concurrent users. If they don't
mind since it's a reporting server, lucky you.
joe.
"ChrisR" <noFudgingWay@.NoEmail.com> wrote in message
news:OVIC2SRDHHA.4832@.TK2MSFTNGP06.phx.gbl...
> Thank you David. Do you happen to know if it can be done without an SP or
> not? We replicate a lot of data to a "reporting box", with the sole
> purpose
> in mind of developers and power users being able to query their own data.
> Thanks again.
>
> "David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
> news:1164063291.160874.187260@.b28g2000cwb.googlegr oups.com...
> ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/38e9bf58-10c6-46ed-83cb-e2d7
> an
> while
>
|||Thanks Joe. I understand the importance of security, but (unfortunately) the
powers that be want to be able to directly query their data. You brought up
a good point though that I hadn't thought of, passing out the encryption key
is a strong arguement, and won I can probably win.
Thanks!
"Joe Yong" <NO_jyong@.SPAM_scalabilityexperts.com> wrote in message
news:excTblRDHHA.4404@.TK2MSFTNGP03.phx.gbl...
> The whole ide of using an SP is to provide access to the data without
> granting permissions to the base table. Can you avoid using an SP? Sure
but
> that means you will end up providing access to the encryption key and
table
> which is usually not a good thing to do if you are really concerned about
> security.
> You could tweak the SP to have parameter for the calling userID (assuming
> you have some way to determine the rows for "permitted" users) and filter
> the results with a where clause but that can be a sizeable perf hit if
> you're dealing with large tables and/or many concurrent users. If they
don't[vbcol=seagreen]
> mind since it's a reporting server, lucky you.
>
> joe.
> "ChrisR" <noFudgingWay@.NoEmail.com> wrote in message
> news:OVIC2SRDHHA.4832@.TK2MSFTNGP06.phx.gbl...
or[vbcol=seagreen]
data.[vbcol=seagreen]
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/38e9bf58-10c6-46ed-83cb-e2d7[vbcol=seagreen]
let
>
|||Windows 200 Pro SP4.
SQL 2005 SP1.
I can get the decryption to work as me, but if I open up a new connection
with my test user, it returns NULL values instead of the decrypted data.
This is even if I create a proc and grant exec rights to the test user. Here
is precisely what I did:
USE AdventureWorks;
GO
--If there is no master key, create one now
IF NOT EXISTS
(SELECT * FROM sys.symmetric_keys WHERE symmetric_key_id = 101)
CREATE MASTER KEY ENCRYPTION BY
PASSWORD =
'23987hxJKL95QYV4369#ghf0%94467GRdkjuw54ie5y01478d Dkjdahflkujaslekjg5k3fd117
r$$#1946kcj$n44ncjhdlj'
GO
CREATE CERTIFICATE HumanResources037
WITH SUBJECT = 'Employee Social Security Numbers';
GO
CREATE SYMMETRIC KEY SSN_Key_01
WITH ALGORITHM = DES
ENCRYPTION BY CERTIFICATE HumanResources037;
GO
USE [AdventureWorks];
GO
-- Create a column in which to store the encrypted data
ALTER TABLE HumanResources.Employee
ADD EncryptedNationalIDNumber varbinary(128);
GO
-- Open the symmetric key with which to encrypt the data
OPEN SYMMETRIC KEY SSN_Key_01
DECRYPTION BY CERTIFICATE HumanResources037;
-- Encrypt the value in column NationalIDNumber with symmetric
-- key SSN_Key_01. Save the result in column EncryptedNationalIDNumber.
UPDATE HumanResources.Employee
SET EncryptedNationalIDNumber = EncryptByKey(Key_GUID('SSN_Key_01'),
NationalIDNumber);
GO
-- Verify the encryption.
-- First, open the symmetric key with which to decrypt the data
OPEN SYMMETRIC KEY SSN_Key_01
DECRYPTION BY CERTIFICATE HumanResources037;
GO
-- Now list the original ID, the encrypted ID, and the
-- decrypted ciphertext. If the decryption worked, the original
-- and the decrypted ID will match.
create procedure getDecryptedIDNumber
as
SELECT NationalIDNumber, EncryptedNationalIDNumber
AS "Encrypted ID Number",
CONVERT(nvarchar, DecryptByKey(EncryptedNationalIDNumber))
AS "Decrypted ID Number"
FROM HumanResources.Employee;
GO
/*works for me*/
exec getDecryptedIDNumber
USE [master]
GO
CREATE LOGIN [test] WITH PASSWORD=N'test',
DEFAULT_DATABASE=[AdventureWorks], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
GO
USE [AdventureWorks]
GO
CREATE USER [test] FOR LOGIN [test]
GO
use [AdventureWorks]
GO
GRANT EXECUTE ON [dbo].[getDecryptedIDNumber] TO [test]
GO
/*Now, open up a "file/new/DB Engine Query" and login with the test login*/
exec getDecryptedIDNumber
/*This returns NULL values where it should show the decrypted data*/
Can someone please assist?
TIA, ChrisR
|||You're missing the "EXECUTE AS OWNER" or execute as something-or-other
clause in your create procedure statement. If you don't have that clause, it
will default to execute as caller which means any user executing that sproc
will be checked for permissions and if it isn't granted, you get null values
in your SELECT.
joe.
"ChrisR" <noFudgingWay@.NoEmail.com> wrote in message
news:ONry7jYDHHA.3524@.TK2MSFTNGP06.phx.gbl...
> Windows 200 Pro SP4.
> SQL 2005 SP1.
> I can get the decryption to work as me, but if I open up a new connection
> with my test user, it returns NULL values instead of the decrypted data.
> This is even if I create a proc and grant exec rights to the test user.
> Here
> is precisely what I did:
>
> USE AdventureWorks;
> GO
>
> --If there is no master key, create one now
> IF NOT EXISTS
> (SELECT * FROM sys.symmetric_keys WHERE symmetric_key_id = 101)
> CREATE MASTER KEY ENCRYPTION BY
> PASSWORD =
> '23987hxJKL95QYV4369#ghf0%94467GRdkjuw54ie5y01478d Dkjdahflkujaslekjg5k3fd117
> r$$#1946kcj$n44ncjhdlj'
> GO
>
> CREATE CERTIFICATE HumanResources037
> WITH SUBJECT = 'Employee Social Security Numbers';
> GO
>
> CREATE SYMMETRIC KEY SSN_Key_01
> WITH ALGORITHM = DES
> ENCRYPTION BY CERTIFICATE HumanResources037;
> GO
>
> USE [AdventureWorks];
> GO
>
> -- Create a column in which to store the encrypted data
> ALTER TABLE HumanResources.Employee
> ADD EncryptedNationalIDNumber varbinary(128);
> GO
>
> -- Open the symmetric key with which to encrypt the data
> OPEN SYMMETRIC KEY SSN_Key_01
> DECRYPTION BY CERTIFICATE HumanResources037;
>
> -- Encrypt the value in column NationalIDNumber with symmetric
> -- key SSN_Key_01. Save the result in column EncryptedNationalIDNumber.
> UPDATE HumanResources.Employee
> SET EncryptedNationalIDNumber = EncryptByKey(Key_GUID('SSN_Key_01'),
> NationalIDNumber);
> GO
>
> -- Verify the encryption.
> -- First, open the symmetric key with which to decrypt the data
> OPEN SYMMETRIC KEY SSN_Key_01
> DECRYPTION BY CERTIFICATE HumanResources037;
> GO
>
> -- Now list the original ID, the encrypted ID, and the
> -- decrypted ciphertext. If the decryption worked, the original
> -- and the decrypted ID will match.
> create procedure getDecryptedIDNumber
> as
> SELECT NationalIDNumber, EncryptedNationalIDNumber
> AS "Encrypted ID Number",
> CONVERT(nvarchar, DecryptByKey(EncryptedNationalIDNumber))
> AS "Decrypted ID Number"
> FROM HumanResources.Employee;
> GO
>
> /*works for me*/
> exec getDecryptedIDNumber
>
> USE [master]
> GO
> CREATE LOGIN [test] WITH PASSWORD=N'test',
> DEFAULT_DATABASE=[AdventureWorks], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
> GO
> USE [AdventureWorks]
> GO
> CREATE USER [test] FOR LOGIN [test]
> GO
>
> use [AdventureWorks]
> GO
> GRANT EXECUTE ON [dbo].[getDecryptedIDNumber] TO [test]
> GO
>
> /*Now, open up a "file/new/DB Engine Query" and login with the test
> login*/
>
> exec getDecryptedIDNumber
>
> /*This returns NULL values where it should show the decrypted data*/
>
> Can someone please assist?
>
> TIA, ChrisR
>
>
|||Thanks Joe, but I just tried:
ALTER procedure [dbo].[getDecryptedIDNumber]
with execute as 'dbo'
as
SELECT NationalIDNumber, EncryptedNationalIDNumber
AS "Encrypted ID Number",
CONVERT(nvarchar, DecryptByKey(EncryptedNationalIDNumber))
AS "Decrypted ID Number"
FROM HumanResources.Employee;
use [AdventureWorks]
GO
GRANT IMPERSONATE ON USER::[dbo] TO [test]
GO
exec as user = 'dbo'
exec getDecryptedIDNumber
and it still comes back as NULL. Any other ideas?
"Joe Yong" <NO_jyong@.SPAM_scalabilityexperts.com> wrote in message
news:ONp1UqeDHHA.1196@.TK2MSFTNGP02.phx.gbl...
> You're missing the "EXECUTE AS OWNER" or execute as something-or-other
> clause in your create procedure statement. If you don't have that clause,
it
> will default to execute as caller which means any user executing that
sproc
> will be checked for permissions and if it isn't granted, you get null
values[vbcol=seagreen]
> in your SELECT.
>
> joe.
>
> "ChrisR" <noFudgingWay@.NoEmail.com> wrote in message
> news:ONry7jYDHHA.3524@.TK2MSFTNGP06.phx.gbl...
connection[vbcol=seagreen]
'23987hxJKL95QYV4369#ghf0%94467GRdkjuw54ie5y01478d Dkjdahflkujaslekjg5k3fd117[vbcol=seagreen]
CHECK_POLICY=OFF
>

Decrypt permissions?

Howdy all. I just did the BOL example of encrypting a column of data:
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/38e9bf58-10c6-46ed-83cb-e2d7
6cda0adc.htm
and it worked great. However, Ive been trying to figure out how to let an
end user (someone with just read permissions) decrypt the data for a while
now to no avail. Can someone please assist? Also, I had to use "
WITH ALGORITHM = DES"
instead of what BOL said to to my version of SQL Server.
TIA, ChrisRChrisR wrote:
> Howdy all. I just did the BOL example of encrypting a column of data:
> ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/38e9bf58-10c6-46ed-83cb-e2
d7
> 6cda0adc.htm
> and it worked great. However, Ive been trying to figure out how to let an
> end user (someone with just read permissions) decrypt the data for a while
> now to no avail. Can someone please assist? Also, I had to use "
> WITH ALGORITHM = DES"
> instead of what BOL said to to my version of SQL Server.
> TIA, ChrisR
The end user can access the data through a stored proc that decrypts
the data for him. Stored procs are the preferred method for data access
whether or not the data is encrypted. Execute permission is all that
the user will need.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||Thank you David. Do you happen to know if it can be done without an SP or
not? We replicate a lot of data to a "reporting box", with the sole purpose
in mind of developers and power users being able to query their own data.
Thanks again.
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:1164063291.160874.187260@.b28g2000cwb.googlegroups.com...
> ChrisR wrote:
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/38e9bf58-10c6-46ed-83cb-e2d7[vbcol=seagreen]
an[vbcol=seagreen]
while[vbcol=seagreen]
> The end user can access the data through a stored proc that decrypts
> the data for him. Stored procs are the preferred method for data access
> whether or not the data is encrypted. Execute permission is all that
> the user will need.
> --
> David Portas, SQL Server MVP
> Whenever possible please post enough code to reproduce your problem.
> Including CREATE TABLE and INSERT statements usually helps.
> State what version of SQL Server you are using and specify the content
> of any error messages.
> SQL Server Books Online:
> http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
> --
>|||The whole ide of using an SP is to provide access to the data without
granting permissions to the base table. Can you avoid using an SP? Sure but
that means you will end up providing access to the encryption key and table
which is usually not a good thing to do if you are really concerned about
security.
You could tweak the SP to have parameter for the calling userID (assuming
you have some way to determine the rows for "permitted" users) and filter
the results with a where clause but that can be a sizeable perf hit if
you're dealing with large tables and/or many concurrent users. If they don't
mind since it's a reporting server, lucky you.
joe.
"ChrisR" <noFudgingWay@.NoEmail.com> wrote in message
news:OVIC2SRDHHA.4832@.TK2MSFTNGP06.phx.gbl...
> Thank you David. Do you happen to know if it can be done without an SP or
> not? We replicate a lot of data to a "reporting box", with the sole
> purpose
> in mind of developers and power users being able to query their own data.
> Thanks again.
>
> "David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
> news:1164063291.160874.187260@.b28g2000cwb.googlegroups.com...
> ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/38e9bf58-10c6-46ed-83cb-e2
d7
> an
> while
>|||Thanks Joe. I understand the importance of security, but (unfortunately) the
powers that be want to be able to directly query their data. You brought up
a good point though that I hadn't thought of, passing out the encryption key
is a strong arguement, and won I can probably win.
Thanks!
"Joe Yong" <NO_jyong@.SPAM_scalabilityexperts.com> wrote in message
news:excTblRDHHA.4404@.TK2MSFTNGP03.phx.gbl...
> The whole ide of using an SP is to provide access to the data without
> granting permissions to the base table. Can you avoid using an SP? Sure
but
> that means you will end up providing access to the encryption key and
table
> which is usually not a good thing to do if you are really concerned about
> security.
> You could tweak the SP to have parameter for the calling userID (assuming
> you have some way to determine the rows for "permitted" users) and filter
> the results with a where clause but that can be a sizeable perf hit if
> you're dealing with large tables and/or many concurrent users. If they
don't
> mind since it's a reporting server, lucky you.
>
> joe.
> "ChrisR" <noFudgingWay@.NoEmail.com> wrote in message
> news:OVIC2SRDHHA.4832@.TK2MSFTNGP06.phx.gbl...
or[vbcol=seagreen]
data.[vbcol=seagreen]
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/38e9bf58-10c6-46ed-83cb-e2d7[vbcol=seagreen]
let[vbcol=seagreen]
>|||Windows 200 Pro SP4.
SQL 2005 SP1.
I can get the decryption to work as me, but if I open up a new connection
with my test user, it returns NULL values instead of the decrypted data.
This is even if I create a proc and grant exec rights to the test user. Here
is precisely what I did:
USE AdventureWorks;
GO
--If there is no master key, create one now
IF NOT EXISTS
(SELECT * FROM sys.symmetric_keys WHERE symmetric_key_id = 101)
CREATE MASTER KEY ENCRYPTION BY
PASSWORD =
'23987hxJKL95QYV4369#ghf0%94467GRdkjuw54
ie5y01478dDkjdahflkujaslekjg5k3fd117
r$$#1946kcj$n44ncjhdlj'
GO
CREATE CERTIFICATE HumanResources037
WITH SUBJECT = 'Employee Social Security Numbers';
GO
CREATE SYMMETRIC KEY SSN_Key_01
WITH ALGORITHM = DES
ENCRYPTION BY CERTIFICATE HumanResources037;
GO
USE [AdventureWorks];
GO
-- Create a column in which to store the encrypted data
ALTER TABLE HumanResources.Employee
ADD EncryptedNationalIDNumber varbinary(128);
GO
-- Open the symmetric key with which to encrypt the data
OPEN SYMMETRIC KEY SSN_Key_01
DECRYPTION BY CERTIFICATE HumanResources037;
-- Encrypt the value in column NationalIDNumber with symmetric
-- key SSN_Key_01. Save the result in column EncryptedNationalIDNumber.
UPDATE HumanResources.Employee
SET EncryptedNationalIDNumber = EncryptByKey(Key_GUID('SSN_Key_01'),
NationalIDNumber);
GO
-- Verify the encryption.
-- First, open the symmetric key with which to decrypt the data
OPEN SYMMETRIC KEY SSN_Key_01
DECRYPTION BY CERTIFICATE HumanResources037;
GO
-- Now list the original ID, the encrypted ID, and the
-- decrypted ciphertext. If the decryption worked, the original
-- and the decrypted ID will match.
create procedure getDecryptedIDNumber
as
SELECT NationalIDNumber, EncryptedNationalIDNumber
AS "Encrypted ID Number",
CONVERT(nvarchar, DecryptByKey(EncryptedNationalIDNumber))
AS "Decrypted ID Number"
FROM HumanResources.Employee;
GO
/*works for me*/
exec getDecryptedIDNumber
USE [master]
GO
CREATE LOGIN [test] WITH PASSWORD=N'test',
DEFAULT_DATABASE=[AdventureWorks], CHECK_EXPIRATION=OFF, CHECK_POLICY=OF
F
GO
USE [AdventureWorks]
GO
CREATE USER [test] FOR LOGIN [test]
GO
use [AdventureWorks]
GO
GRANT EXECUTE ON [dbo].[getDecryptedIDNumber] TO [test]
GO
/*Now, open up a "file/new/DB Engine Query" and login with the test login*/
exec getDecryptedIDNumber
/*This returns NULL values where it should show the decrypted data*/
Can someone please assist?
TIA, ChrisR|||You're missing the "EXECUTE AS OWNER" or execute as something-or-other
clause in your create procedure statement. If you don't have that clause, it
will default to execute as caller which means any user executing that sproc
will be checked for permissions and if it isn't granted, you get null values
in your SELECT.
joe.
"ChrisR" <noFudgingWay@.NoEmail.com> wrote in message
news:ONry7jYDHHA.3524@.TK2MSFTNGP06.phx.gbl...
> Windows 200 Pro SP4.
> SQL 2005 SP1.
> I can get the decryption to work as me, but if I open up a new connection
> with my test user, it returns NULL values instead of the decrypted data.
> This is even if I create a proc and grant exec rights to the test user.
> Here
> is precisely what I did:
>
> USE AdventureWorks;
> GO
>
> --If there is no master key, create one now
> IF NOT EXISTS
> (SELECT * FROM sys.symmetric_keys WHERE symmetric_key_id = 101)
> CREATE MASTER KEY ENCRYPTION BY
> PASSWORD =
> '23987hxJKL95QYV4369#ghf0%94467GRdkjuw54
ie5y01478dDkjdahflkujaslekjg5k3fd1
17
> r$$#1946kcj$n44ncjhdlj'
> GO
>
> CREATE CERTIFICATE HumanResources037
> WITH SUBJECT = 'Employee Social Security Numbers';
> GO
>
> CREATE SYMMETRIC KEY SSN_Key_01
> WITH ALGORITHM = DES
> ENCRYPTION BY CERTIFICATE HumanResources037;
> GO
>
> USE [AdventureWorks];
> GO
>
> -- Create a column in which to store the encrypted data
> ALTER TABLE HumanResources.Employee
> ADD EncryptedNationalIDNumber varbinary(128);
> GO
>
> -- Open the symmetric key with which to encrypt the data
> OPEN SYMMETRIC KEY SSN_Key_01
> DECRYPTION BY CERTIFICATE HumanResources037;
>
> -- Encrypt the value in column NationalIDNumber with symmetric
> -- key SSN_Key_01. Save the result in column EncryptedNationalIDNumber.
> UPDATE HumanResources.Employee
> SET EncryptedNationalIDNumber = EncryptByKey(Key_GUID('SSN_Key_01'),
> NationalIDNumber);
> GO
>
> -- Verify the encryption.
> -- First, open the symmetric key with which to decrypt the data
> OPEN SYMMETRIC KEY SSN_Key_01
> DECRYPTION BY CERTIFICATE HumanResources037;
> GO
>
> -- Now list the original ID, the encrypted ID, and the
> -- decrypted ciphertext. If the decryption worked, the original
> -- and the decrypted ID will match.
> create procedure getDecryptedIDNumber
> as
> SELECT NationalIDNumber, EncryptedNationalIDNumber
> AS "Encrypted ID Number",
> CONVERT(nvarchar, DecryptByKey(EncryptedNationalIDNumber))
> AS "Decrypted ID Number"
> FROM HumanResources.Employee;
> GO
>
> /*works for me*/
> exec getDecryptedIDNumber
>
> USE [master]
> GO
> CREATE LOGIN [test] WITH PASSWORD=N'test',
> DEFAULT_DATABASE=[AdventureWorks], CHECK_EXPIRATION=OFF, CHECK_POLICY=
OFF
> GO
> USE [AdventureWorks]
> GO
> CREATE USER [test] FOR LOGIN [test]
> GO
>
> use [AdventureWorks]
> GO
> GRANT EXECUTE ON [dbo].[getDecryptedIDNumber] TO [test]
> GO
>
> /*Now, open up a "file/new/DB Engine Query" and login with the test
> login*/
>
> exec getDecryptedIDNumber
>
> /*This returns NULL values where it should show the decrypted data*/
>
> Can someone please assist?
>
> TIA, ChrisR
>
>|||Thanks Joe, but I just tried:
ALTER procedure [dbo].[getDecryptedIDNumber]
with execute as 'dbo'
as
SELECT NationalIDNumber, EncryptedNationalIDNumber
AS "Encrypted ID Number",
CONVERT(nvarchar, DecryptByKey(EncryptedNationalIDNumber))
AS "Decrypted ID Number"
FROM HumanResources.Employee;
use [AdventureWorks]
GO
GRANT IMPERSONATE ON USER::[dbo] TO [test]
GO
exec as user = 'dbo'
exec getDecryptedIDNumber
and it still comes back as NULL. Any other ideas?
"Joe Yong" <NO_jyong@.SPAM_scalabilityexperts.com> wrote in message
news:ONp1UqeDHHA.1196@.TK2MSFTNGP02.phx.gbl...
> You're missing the "EXECUTE AS OWNER" or execute as something-or-other
> clause in your create procedure statement. If you don't have that clause,
it
> will default to execute as caller which means any user executing that
sproc
> will be checked for permissions and if it isn't granted, you get null
values
> in your SELECT.
>
> joe.
>
> "ChrisR" <noFudgingWay@.NoEmail.com> wrote in message
> news:ONry7jYDHHA.3524@.TK2MSFTNGP06.phx.gbl...
connection[vbcol=seagreen]
'23987hxJKL95QYV4369#ghf0%94467GRdkjuw54
ie5y01478dDkjdahflkujaslekjg5k3fd117[vbc
ol=seagreen]
CHECK_POLICY=OFF[vbcol=seagreen]
>

Saturday, February 25, 2012

Debugging triggers, how?

I could find that its possible to debug stored procedures in SQl server
2000, but did not find any place in BOL where it was explained if it was
even possible to debug (step through and verify values obtained as well as
detect programming errors other than syntax errors) triggers. Is it
possible, if so where do I find Info on how?
Thanks fir any help,
BobBob,
I believe the Transact-SQL Debugger does not work directly with triggers.
However, I believe I read somewhere that it will work if the stored
procedure is being debugged and it fires the trigger.
Other possible options may include embedding additional t-shooting code in
the trigger i.e., RAISERROR or SELECT (INSERTED/DELETED).
HTH
Jerry
"Bob" <bdufour@.sgiims.com> wrote in message
news:OSET%23QQ0FHA.460@.TK2MSFTNGP15.phx.gbl...
>I could find that its possible to debug stored procedures in SQl server
>2000, but did not find any place in BOL where it was explained if it was
>even possible to debug (step through and verify values obtained as well as
>detect programming errors other than syntax errors) triggers. Is it
>possible, if so where do I find Info on how?
> Thanks fir any help,
> Bob
>|||On Fri, 14 Oct 2005 17:13:09 -0400, Bob wrote:

>I could find that its possible to debug stored procedures in SQl server
>2000, but did not find any place in BOL where it was explained if it was
>even possible to debug (step through and verify values obtained as well as
>detect programming errors other than syntax errors) triggers. Is it
>possible, if so where do I find Info on how?
>Thanks fir any help,
>Bob
>
Hi Bob,
Jerry is right:
1. Create a procedure that performs an insert, update or delete that
would fire the trigger.
2. Debug the stored procedure
3. Step into the trigger.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)|||Jerry is correct.
You can't debug triggers directly but if you are debugging a stored proc and
a trigger is fired, then it will step in debug mode inside the trigger.
Yosh
"Jerry Spivey" <jspivey@.vestas-awt.com> wrote in message
news:eURZtZQ0FHA.664@.tk2msftngp13.phx.gbl...
> Bob,
> I believe the Transact-SQL Debugger does not work directly with triggers.
> However, I believe I read somewhere that it will work if the stored
> procedure is being debugged and it fires the trigger.
> Other possible options may include embedding additional t-shooting code in
> the trigger i.e., RAISERROR or SELECT (INSERTED/DELETED).
> HTH
> Jerry
> "Bob" <bdufour@.sgiims.com> wrote in message
> news:OSET%23QQ0FHA.460@.TK2MSFTNGP15.phx.gbl...
>|||Excellent suggestion Hugo!
This would work perfectly.
Yosh
"Hugo Kornelis" <hugo@.pe_NO_rFact.in_SPAM_fo> wrote in message
news:qnc0l1d6bke8sv0pcpl9feb1qbkmbjtumr@.
4ax.com...
> On Fri, 14 Oct 2005 17:13:09 -0400, Bob wrote:
>
> Hi Bob,
> Jerry is right:
> 1. Create a procedure that performs an insert, update or delete that
> would fire the trigger.
> 2. Debug the stored procedure
> 3. Step into the trigger.
> Best, Hugo
> --
> (Remove _NO_ and _SPAM_ to get my e-mail address)|||Thank you all,
Bob
"Bob" <bdufour@.sgiims.com> wrote in message
news:OSET%23QQ0FHA.460@.TK2MSFTNGP15.phx.gbl...
>I could find that its possible to debug stored procedures in SQl server
>2000, but did not find any place in BOL where it was explained if it was
>even possible to debug (step through and verify values obtained as well as
>detect programming errors other than syntax errors) triggers. Is it
>possible, if so where do I find Info on how?
> Thanks fir any help,
> Bob
>

Friday, February 24, 2012

Debugging SPs in SQL Server 2005

Hi,
Are there any new feature for debugging non-CLR SPs in Management Studio? I
couldn't find anything in BOL.
Thanks in advance,
LeilaThere's no debugger of TSQL code in Management Studio. You have to use Visua
l Studio for that.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Leila" <Leilas@.hotpop.com> wrote in message news:%23ZJkGf4GGHA.3000@.TK2MSFTNGP14.phx.gbl..
.
> Hi,
> Are there any new feature for debugging non-CLR SPs in Management Studio?
I
> couldn't find anything in BOL.
> Thanks in advance,
> Leila
>

Debugging SPs in SQL Server 2005

Hi,
Are there any new feature for debugging non-CLR SPs in Management Studio? I
couldn't find anything in BOL.
Thanks in advance,
Leila
There's no debugger of TSQL code in Management Studio. You have to use Visual Studio for that.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Leila" <Leilas@.hotpop.com> wrote in message news:%23ZJkGf4GGHA.3000@.TK2MSFTNGP14.phx.gbl...
> Hi,
> Are there any new feature for debugging non-CLR SPs in Management Studio? I
> couldn't find anything in BOL.
> Thanks in advance,
> Leila
>

Debugging SPs in SQL Server 2005

Hi,
Are there any new feature for debugging non-CLR SPs in Management Studio? I
couldn't find anything in BOL.
Thanks in advance,
LeilaThere's no debugger of TSQL code in Management Studio. You have to use Visual Studio for that.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Leila" <Leilas@.hotpop.com> wrote in message news:%23ZJkGf4GGHA.3000@.TK2MSFTNGP14.phx.gbl...
> Hi,
> Are there any new feature for debugging non-CLR SPs in Management Studio? I
> couldn't find anything in BOL.
> Thanks in advance,
> Leila
>

Debugging SPs in SQL Server 2005

Hi,
Are there any new feature for debugging non-CLR SPs in Management Studio? I
couldn't find anything in BOL.
Thanks in advance,
LeilaThere's no debugger of TSQL code in Management Studio. You have to use Visua
l Studio for that.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Leila" <Leilas@.hotpop.com> wrote in message news:%23ZJkGf4GGHA.3000@.TK2MSFTNGP14.phx.gbl...

> Hi,
> Are there any new feature for debugging non-CLR SPs in Management Studio?
I
> couldn't find anything in BOL.
> Thanks in advance,
> Leila
>

Sunday, February 19, 2012

Debugging in SSIS - Immediate and Command windows

Hi everyone,
I am having a difficult time debugging a package that I'm working on. I read in BOL that the immediate window should be an option during debugging but I can't find it anywhere(nor can I enable it), and I was planning on using it to access an oledb source property that is using an expression. Is the command window the same as immediate? I didn't orignally think so but I'm not sure. What is the syntax to use for this once I find it?
Thanks,
Adrian

You can't access runtime values of an oledb source property but you can see what data going downstream using visualizers.

Command window isn't supported.

Can you give me a ref where in BOL you found about immediate window?

|||Nick, thanks for responding, I didn't see that anyone had responed until now.
I found it here:
ms-help://MS.VSCC.v80/MS.VSIPCC.v80/MS.SQLSVR.v9.en/extran9/html/54a458cc-9f4f-4b48-8cf2-db2e0fa7756c.htm

Adrian

Debugging in SQL2005

Hi,
How can you debug a stored procedure in SQL2005? I cannot find anything in
BOL (Sept CTP).
Thanks
Chris WoodChris,
Please see:
http://www.aspfaq.com/sql2005/show.asp?id=1
HTH
Jerry
"Chris Wood" <anonymous@.discussions.microsoft.com> wrote in message
news:%23UZcW$L1FHA.1040@.TK2MSFTNGP14.phx.gbl...
> Hi,
> How can you debug a stored procedure in SQL2005? I cannot find anything in
> BOL (Sept CTP).
> Thanks
> Chris Wood
>|||Chris,
If you have installed only SQL Server 2005 you will find limited
information in BOL if you search on "debugging stored procedures".
If you have Visual Studio 2005 also installed on the machine the same
search in the document explorer which combines MSDN and BOL for search
will give you more information that is relevant.
Andrew Watt
MVP - InfoPath
On Wed, 19 Oct 2005 09:14:43 -0600, "Chris Wood"
<anonymous@.discussions.microsoft.com> wrote:
>Hi,
>How can you debug a stored procedure in SQL2005? I cannot find anything in
>BOL (Sept CTP).
>Thanks
>Chris Wood|||We do not have VS2005 on the server.
Thanks
Chris
"Andrew Watt [MVP - InfoPath]" <SVGDeveloper@.aol.com> wrote in message
news:hmpcl1psevgsvjtl5p5401fnmr0a98rqgk@.4ax.com...
> Chris,
> If you have installed only SQL Server 2005 you will find limited
> information in BOL if you search on "debugging stored procedures".
> If you have Visual Studio 2005 also installed on the machine the same
> search in the document explorer which combines MSDN and BOL for search
> will give you more information that is relevant.
> Andrew Watt
> MVP - InfoPath
> On Wed, 19 Oct 2005 09:14:43 -0600, "Chris Wood"
> <anonymous@.discussions.microsoft.com> wrote:
>>Hi,
>>How can you debug a stored procedure in SQL2005? I cannot find anything in
>>BOL (Sept CTP).
>>Thanks
>>Chris Wood
>|||MSDN subscribers can, I believe, download the VS2005 Release Candidate
which includes the additional documentation I mentioned.
Andrew Watt
MVP - InfoPath
On Wed, 19 Oct 2005 09:44:05 -0600, "Chris Wood"
<anonymous@.discussions.microsoft.com> wrote:
>We do not have VS2005 on the server.
>Thanks
>Chris
>"Andrew Watt [MVP - InfoPath]" <SVGDeveloper@.aol.com> wrote in message
>news:hmpcl1psevgsvjtl5p5401fnmr0a98rqgk@.4ax.com...
>> Chris,
>> If you have installed only SQL Server 2005 you will find limited
>> information in BOL if you search on "debugging stored procedures".
>> If you have Visual Studio 2005 also installed on the machine the same
>> search in the document explorer which combines MSDN and BOL for search
>> will give you more information that is relevant.
>> Andrew Watt
>> MVP - InfoPath
>> On Wed, 19 Oct 2005 09:14:43 -0600, "Chris Wood"
>> <anonymous@.discussions.microsoft.com> wrote:
>>Hi,
>>How can you debug a stored procedure in SQL2005? I cannot find anything in
>>BOL (Sept CTP).
>>Thanks
>>Chris Wood