Wednesday, August 17, 2011

Thursday, August 11, 2011

Cannot use the special principal 'sa'.

ERROR: Cannot use the special principal 'sa'.

SOLUTION: run this command in the query editor window for that database

exec sp_changedbowner 'sa','true'

Wednesday, August 10, 2011

find out which column has the userId = 11 in a database

exec sp_msforeachtable 'Select ''[?]'' as Table_Name, * from ? where userId in (''11'')'

Convert column data from Binary to String with SQL Server

declare @stringPassowrd varchar(max)

select @stringPassowrd = sys.fn_sqlvarbasetostr(UserPassword) from Users where UserID = 2

print @stringPassowrd

where UserPassword is the binary column you would like to convert.