问题描述
我想在桌子上的12张贴纸的A4 Lebel表上打印相同的地址名称。
我使用的是数据列表,无法在12级填充所有,只显示一次。需要重复12次。
SELECT *来自客户,其中CustID ='101'
建议更好的解决方案。
我的尝试:
I want to print same name with address on a A4 Lebel sheet of 12 Sticker from table.
I am using datalist,not able to fill all on 12 level, it shows only one time.It require to repeat 12 times.
SELECT * from Customer where CustID='101'
Suggest better solution.
What I have tried:
SELECT * from Customer where CustID='101'
推荐答案
Counter
1
2
3
4
5
6
7
8
9
10
11
12
然后这是一个简单的JOIN来获得相同的结果12次:
Then it's a simple JOIN to get the same info 12 times:
SELECT a.Name, a.Address FROM Count12 b
JOIN MyTable a ON 1=1
如果使Count表包含1000行,则可以使用WHERE限制副本数:
If you make the Count table contain say 1000 rows, you can restrict the number of copies using WHERE:
SELECT a.Name, a.Email FROM Count12 b
JOIN MyTable a ON 1=1
WHERE b.Counter <= 5
例如,每行会给你5份副本。
你现在还能过得更好用你的演示语言来做。
Will give you 5 copies of each row for example.
You're still better off doing it in your presentation language though.
declare @Customer table (CustID int, CustName nvarchar(100))
insert into @Customer (CustID, CustName) values (101, 'My test data')
;with series as
(
select 1 as datum
UNION ALL
select datum + 1
from series where datum + 1 < 13
)
SELECT * from @Customer
cross join series
where CustID=101
或者您可以使用系统表生成这样的序列
OR you can use the system tables to generate a sequence like this
SELECT * from @Customer
CROSS JOIN (SELECT TOP (12) ROW_NUMBER() OVER (ORDER BY [object_id]) as datum FROM sys.all_objects) AS series
WHERE CustID=101
这篇关于在datalist中重复相同的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!