I am trying to use STRING_AGG function in a INT column. And getting a implicit type conversion warning. I think its affecting my query performance. How can I avoid this?
Here's the query:
SELECT
STRING_AGG(ES.SomeIntID, '#') AS Something
FROM SomeTable
GROUP BY OtherID
I have tried to convert/cast the SomeIntID value explicitly to INT and NVARCHAR(12) but no improvement.
The warning:
convert_issue: Cardinality Estimate
expression: CONVERT(nvarchar(12), SomeIntID, 0)
It's significant as this function is being used multiple times in the query. I think this conversion is increasing my WorkFile/WorkTable logical read too.
Attempted query to convert:
STRING_AGG(CAST(ES.SomeIntID as nvarchar(12)), N'#') AS Something
AND
STRING_AGG(CAST(ES.SomeIntID as varchar(12)), '#') AS Something