SQL


DECLARE @counter int = 1;
DECLARE @colString varchar(10) = 'AA%#&    ';

WHILE @counter <= DATALENGTH(@colString)
   BEGIN
   SELECT CHAR(ASCII(SUBSTRING(@colString, @counter, 1))) as [Character],
   ASCII(SUBSTRING(@colString, @counter, 1)) as [ASCIIValue]
     
   SET @counter = @counter + 1
   END
GO

Credit to Source

Backed up and restored a database the other day, but of course the network users arent setup properly cause there actually stored in the master database..

So i recreate the user on the instance which is fine , and then try and regrant it permissions on the database but it fails because its already there…

To fix…

User DATABASE
EXEC sp_change_users_login 'update_one', 'usernamehere', 'usernamehere''

http://msdn.microsoft.com/en-us/library/ms174378.aspx

Rounds Timefieldhere to the nearest 5 minutes..

trunc(timefieldhere,'dd') + round(to_char(timefieldhere,'sssss') / 300) / 288)