June 16, 2004 at 4:28 am
CREATE TABLE #user(users varchar(50), passw varchar(50), title varchar(50), fullname VARCHAR(50))
insert into #user select 'stephenj','password1','ceo','James Stephen'
SELECT * FROM #user
alter table #user alter column passw nvarchar(50)
update #user set passw=pwdencrypt(passw)
SELECT * FROM #user
DROP table #user
Running this in QA has strange results.
The title columns has an unreadable value and value in "title" column has moved into "fullname" column. Values in "fullname" column have disappeared.
Actually i had a table with users info and i laterly i changed one of the column to encrypt fields and had a situation demostrated above.
Howdy!
June 16, 2004 at 5:09 am
Try running the query and display the results in text (my preferred DEFAULT) vs. grid. This can be changed in Query > Results in Text (for current session) or permanently or Tools > Options > Results tab
Good Hunting!
AJ Ahrens
webmaster@kritter.net
June 17, 2004 at 1:54 am
pwdencrypt is not a documented feature of SQL Server (in other words, don't use it, get some real encryption).
But hey, in anycase, it returns a varbinary result, not a nvarchar result, so mashing it into a nvarchar will probably earn you problems.
QA is going biserk because its expecting double-byte unicode to come out of the nvarchar column, and your pwdencrypt in nvarchar is probably a byte too long (or makes a \t), so QA is getting mixed up on where the column ends.
The way around this?
CREATE TABLE #user(users varchar(50), passw varchar(50), title varchar(50), fullname VARCHAR(50))
insert into #user select 'stephenj','password1','ceo','James Stephen'
SELECT * FROM #user
alter table #user add passwbin varbinary(256)
update #user set passwbin=pwdencrypt(passw)
alter table #user drop column passw
SELECT * FROM #user
DROP table #user
Julian Kuiters
juliankuiters.id.au
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply