Potential Bug in Azure Synapse Analytics

Lon Fortes 6 Reputation points
2021-02-05T00:58:37.99+00:00

64321-synapsebug.png64331-synapsebug-works.pngI've encountered what appears to be a bug in which string concatenation fails for queries like "select @Kritivasas =" when trying to concat text with a variable using a select statement from a table in DEDICATED SQL POOLS. Works fine in master db . Two screen grabs included. The first query throws an error. The second is a nearly syntactically identical work around.

Code for screenshot 1:

declare @TableObjectId in = object_id('<your valid table here>'),  
		@RangeValue varchar(50)  
  
declare @sql nvarchar(max)  
  
select @sql = 'ALTER TABLE [' + s.[name] + '].[' + t.[name] + '] SPLIT RANGE (''' + @RangeValue + ''')'  
from sys.tables t  
  join sys.schemas s on t.[schema_id] = t.[schema_id]  
where t.[object_id] = @TableObjectId  
  
select @sql  

Code for screenshot 2:

declare @TableObjectId in = object_id('<your valid table here>'),  
		@RangeValue varchar(50)  
  
declare @sql nvarchar(max)  
  
set @sql = (  
	select 'ALTER TABLE [' + s.[name] + '].[' + t.[name] + '] SPLIT RANGE (''' + @RangeValue + ''')'  
	from sys.tables t  
	  join sys.schemas s on t.[schema_id] = t.[schema_id]  
	where t.[object_id] = @TableObjectId  
)  
  
select @sql  
Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,066 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. HimanshuSinha-msft 19,476 Reputation points Microsoft Employee
    2021-02-05T20:43:33.147+00:00

    Hello @Lon Fortes ,
    Thanks for the ask and using the Microsoft Q&A platform .

    This below piece the code should to the trick with the SELECT

    declare @tableobjectid int =  object_id('[dbo].[DimReseller]'),  
    		@rangeValue varchar(50)  ='100'  
    declare @sql nvarchar(max)   
    select @sql = 'ALTER TABLE [s.name ] SPLIT Range (''' + @rangeValue +''')  
                 from sys.tables t  
    			 join sys.schemas s on t.[schema_id] = s.[schema_id]  
    			 where t.[object_id] =' + convert(varchar,@tableobjectid)  
    
    print @sql   
    

    Output

    ALTER TABLE [s.name ] SPLIT Range ('100')  
                 from sys.tables t  
    			 join sys.schemas s on t.[schema_id] = s.[schema_id]  
    			 where t.[object_id] =2098106515  
    

    Thanks
    Himanshu
    Please do consider to click on "Accept Answer" and "Up-vote" on the post that helps you, as it can be beneficial to other community members


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.