SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


decrypt to date datatype


decrypt to date datatype

Author
Message
jjturner
jjturner
Old Hand
Old Hand (354 reputation)Old Hand (354 reputation)Old Hand (354 reputation)Old Hand (354 reputation)Old Hand (354 reputation)Old Hand (354 reputation)Old Hand (354 reputation)Old Hand (354 reputation)

Group: General Forum Members
Points: 354 Visits: 532
I accidentally used date data type (rather than datetime) to encrypt a column. As I understood from online research, that necessarily entailed conversion to varbinary(200) to begin with, then encrypt.

Now I need to decrypt it:
select convert(varbinary(200), decryptbykey(encrypteddate)) myvarbincol from mytable

.. works fine,
but when I try to convert it back to date:
select convert(date,convert(varbinary(200), decryptbykey(encrypteddate))) mydatecol from mytable

.. it yells at me, and I can't use it to insert or update my destination columns.
Msg 241, Level 16, State 1, Line 1
Conversion failed when converting date and/or time from character string.


Any way to get this into a datetime without starting over?
jjturner
jjturner
Old Hand
Old Hand (354 reputation)Old Hand (354 reputation)Old Hand (354 reputation)Old Hand (354 reputation)Old Hand (354 reputation)Old Hand (354 reputation)Old Hand (354 reputation)Old Hand (354 reputation)

Group: General Forum Members
Points: 354 Visits: 532
closing this out and trying msdn
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search