Wednesday, 26 May 2021
Curious About Cryptographic Boolean Functions?
Sunday, 25 April 2021
Exploring What a PhD Is Like
Some
weeks ago, it was my pleasure, and honour, to be invited to participate as a
panellist in the online event Explore What a PhD is Like organised by PhD Social Support Network from Loughborough
University. The event
aimed to give undergraduate and postgraduate students a summary of Doctoral
Researchers’ lives and an idea of what it’s like to do a PhD at Loughborough
University.
With so much confusing and contradictory information out there, it becomes a bit difficult to have a good understanding of many things before embarking on doing a PhD. So I decided to write down my answers for those of you who could not attend the event and are interested in doing a PhD. Because we were four panellists, I just answered some questions, but in this post, I share my answers to all questions, which mainly depend on my personal circumstances and experiences at Loughborough University — And I do hope to help clear some things up. In case that you have any other questions, please let me know in the comment section.
Thursday, 4 March 2021
Don't Place the Blame on SQL Server
No matter what technology we are working with, we are at the wheel — technology is just a tool — so it is not the best to blame technology on the ground of one's inefficiency.
Monday, 22 February 2021
Cryptography is Everywhere
The huge desire for secrecy led nations, kings, and queens to make all-out efforts to ensure the security of communications by inventing the best possible secret codes and ciphers.
![]() |
A lover in Victorian times |
Friday, 15 January 2021
Do You Want to Be a Cryptographer?
![]() |
Alan Turing |
Monday, 30 July 2018
Installing a stand-alone SQL Server 2017 instance step by step
Today's post is going to outline the process of installing a basic stand-alone SQL Server 2017 instance. This process is just a basic guideline and, surely, not a rule for each installation, because it is fully understood that every environment is different and needs a customised installation to meet very specific requirements. You can read the whole tip about it at mssqltips here https://www.mssqltips.com/sqlservertip/5616/steps-to-install-a-standalone-sql-server-2017-instance. I hope you find it very useful and practical. That's all for now. Please let me know any remarks you may have. Stay tuned!
Tuesday, 20 March 2018
Configuring Read-Only Routing and load-balancing across Read-Only replicas
Saturday, 17 February 2018
Quickly Checking for Stale Statistics in SQL Server
- How often have you faced unforeseen performance issues, even after completing your regular database maintenance tasks?
- Have you wondered why tasks like index rebuilding and statistics updates are sometimes insufficient?
- If everything was running smoothly before, why has performance suddenly declined?
- Why are indexes not being utilised as expected? Should more indexes be created?
Tuesday, 13 February 2018
Avoid changing default ANSI database options
Msg 8152, Level 16, State 14, Line 5
String or binary data would be truncated.
Sunday, 21 January 2018
How to make uniform all the collations of table columns for all databases
To give you just an example, we can start finding out what character columns are using different collations from SQL_Latin1_General_CP1_CI_AS that we need to change in order to make everything uniform. I am going to display a useful script to do it. In this example I am assuming that we want to use SQL_Latin1_General_CP1_CI_AS for all objects in the database server.
EXEC sp_MSforeachdb ' USE [?] select db_name(),c.name from sys.columns c inner join sys.types t on t.user_type_id= c.user_type_id inner join sys.tables tb on c.object_id=tb.object_id where c.collation_name is not null and t.is_user_defined=0 and tb.is_ms_shipped=0 and tb.name<>''sysdiagrams'' and c.collation_name<>''SQL_Latin1_General_CP1_CI_AS'' order by tb.name, c.column_id'
EXEC sp_MSforeachdb ' USE [?] if db_name() not in (''master'',''tempdb'',''msdb'',''model'') begin select replace( REPLACE( ''ALTER TABLE '' + QUOTENAME(SCHEMA_NAME(tb.schema_id)) + ''.'' + QUOTENAME(tb.name) + '' ALTER COLUMN '' + QUOTENAME(c.name) + '' '' + QUOTENAME(t.name) + ''('' + CAST( case when T.NAME=''NVARCHAR'' THEN c.max_length/2 WHEN T.NAME=''NCHAR'' THEN c.max_length/2 ELSE c.max_length END AS VARCHAR(10)) +'')'' + '' COLLATE SQL_Latin1_General_CP1_CI_AS'' + CASE WHEN c.is_nullable =1 THEN '' NULL '' else '' NOT NULL ;'' END, ''-1'', ''MAX'' ), ''[text](16)'', ''[varchar](max)'') as cmd INTO #TblTMP from sys.columns c inner join sys.types t on t.user_type_id= c.user_type_id inner join sys.tables tb on c.object_id=tb.object_id where c.collation_name is not null and t.is_user_defined=0 and tb.is_ms_shipped=0 and tb.name<>''sysdiagrams'' and c.collation_name<>''SQL_Latin1_General_CP1_CI_AS'' order by tb.name, c.column_id declare @cmd varchar(max) declare c_cmd cursor for select cmd from #TblTMP open c_cmd fetch next from c_cmd into @cmd while (@@fetch_status=0) begin exec( @cmd) fetch next from c_cmd into @cmd end close c_cmd deallocate c_cmd drop table #TblTMP end'
Friday, 12 January 2018
MSSQL_ENG003165: An error was encountered while replication was being restored/removed. The database has been left offline
Msg 3165, Level 16, State 1, Line 1
Database ‘MyDB’ was restored, however an error was encountered while replication was being restored/removed. The database has been left offline. See the topic MSSQL_ENG003165 in SQL Server Books Online.
Msg 3167, Level 16, State 1, Line 1
RESTORE could not start database ‘MyDB’.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
Looking into this case, I could see that the cause was a DDL database trigger which existed inside the database. Let me expand on what I am saying. The database had that trigger to audit some schema changes which were supposed to save into an auditing table. Unfortunately, that auditing table did not exist in the server where the database was being restored, and the deletion of objects of replication settings were not completed, which means that 'sp_restoredbreplication' was not executed correctly. Consequently, the restoration was stopped and SQL Server decided to leave the database OFFLINE.
In order to restore a copy of this database, we need to disable all DDL database triggers before taking its backup. Only then will the database be restored successfully. The other method to deal with this issue is to change the status to ONLINE manually after the restoration finishes unsuccessfully and also execute 'sp_restoredbreplication'.
To sum up, we need to proceed with more cautiousness while working with databases linked to replication. That is all for now. Let me know any remarks you may have. Thanks for reading. Stay tuned.