Live transfer, method collection

xiaoxiao2021-03-06  43

First, Zou Jianli - below is test

- Test Data Declare @t Table (Columns 1 VARCHAR (10)) Insert Into @tselect 'a'union all select' d'union all select 'e'union all select' T'Union All Select 'S'Union All Select '5'Union all succ' 96 '

- Handling Declare @s varchar (8000), @ i Intselect @S = ', @ i = 1select @ s = @ S ', [Column ' Cast (@i as varchar) '] = '' 1 '' ', @ i = @ i 1From @tset @ s = substring (@ s, 2,8000) EXEC (' SELECT ' @ s)

/*--Test Results

Less Lee 1, 2, 3, 4, 5 columns, 5 columns, 6 columns 7 ---- ---- ---- ---- ---- ---- ---- A D e t s 5 96

- * /

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

New Post(0)