Write a combination

xiaoxiao2021-03-14  190

Create Table TB (NO INT, B VARCHAR (10))

INSERT INTO TB SELECT 1, '2' Union All Select 1, '3'Union All Select 1,' 4'Union All Select 2, '5'Union All Select 2,' 6 'Union All SELECT 2,' 7'GO

Create function dbo.fc_str (@no varchar (100)) Returns varchar (100) asbegin declare @SQL varchar (1000) set @ SQL = 'SELECT @ SQL = @ SQL ' ' Cast (b as varchar (100)) From tb where no = @ no return stuff (@ SQL, 1, 1, '') EndGo

SELECT NO, DBO.FC_STR (NO) AS B from Tb Group by NO

转载请注明原文地址:https://www.9cbs.com/read-129290.html

New Post(0)