T-SQL help... short script
Posted on 2013-05-12
As part of a stored procedure I have:
select @sql = '
INSERT INTO ' + @tblTarget + '
SELECT COUNT(DISTINCT ' +REPLACE(@where,',','),COUNT(DISTINCT ') + ')--,0
FROM ' + @tblTarget
This counts the number of entries and puts in the table @tblTarget like:
3 <-- The number of entries are 3 counting A, B and C)
but, I want to have it like:
I know that I have to conncatinate '<' and '>' at either end and possibly use CAST to change the count() as varchar(3) for example.
After a couple of tries, I see that I need some help in the syntax.
Question, How can I change the counts to read like <3> instead of just 3.