Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

How to rewrite the query to not use CONCAT function in SQL Server 2008 R2?

Asked by Anne Bell Apr 16, 2021 288 views 1 answer
Share

About this question

I know that the CONCAT function does not exist in SQL Server prior to 2012. How would i optimize my code to not use the CONCAT function?

SELECT dbname = DB_NAME(), file_name = name, TotalMB = CONVERT(decimal(12,1),size/128.0), UsedMB = CONVERT(decimal(12,1),FILEPROPERTY(name,'SpaceUsed')/128.0), FreeMB = CONVERT(decimal(12,1),(size - FILEPROPERTY(name,'SpaceUsed'))/128.0), Command = CONCAT('USE MASTER; ALTER DATABASE ', DB_NAME(), '; MODIFY FILE (name = ', [name], ', size = ', convert(int,round(1.15 * FILEPROPERTY(name,'SpaceUsed')/128,-1)), 'MB)') FROM sys.database_files WITH (NOLOCK) WHERE type_desc = 'ROWS' ORDER BY file_id;

Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.