Friday, 18 May 2018

SQLTips : CONCAT

The CONCAT function is available from SQL 2016+. It can save you a lot of messing around with adding strings together and coping with NULLS and empty strings.
SELECT CONCAT('The cat sat',' ', 'on', ' ', 'the mat')
GO
 

SELECT CONCAT(NULL, ' and void')
GO

 
DECLARE @int int = 99
DECLARE @varchar varchar(13) = ' red balloons'
SELECT CONCAT(@int,@varchar)
GO

 
DECLARE @varchar varchar(20) = 'The date today is '
DECLARE @dt datetime = GETDATE()
SELECT CONCAT(@varchar,@dt)
GO

Tuesday, 15 May 2018

sp_ms_marksystemobject

On searching for a table I found it to be hidden. Turns out it was marked as 'ms shipped' i.e was a system object.


select * from sys.tables WHERE name = 'sysssislog'


To achieve this yourself you can use sp_ms_marksystemobject

EXEC sp_ms_marksystemobject 'dbo.sysssislog'