我现在正在用 SQL 编写脚本,以便可以在 Powershell 中执行输出以生成报告。代码是这样的。
declare @from datetime, @to datetime
select @from=GETDATE(), @to=GETDATE()+1
SELECT ---$shape500.text='+'"'+'Assignation de Barrières-' + DATENAME(WEEKDAY,@from)+','+DATENAME(MONTH,@from)+' '+DATENAME(DAY,@from)+','+DATENAME(YEAR,@from)+'"'
+'$shape'+cast(ROW_NUMBER()OVER(ORDER BY (SELECT 0)) as varchar)+
'=$page.DrawRectangle'+'('+CAST(X1 as varchar)+','+CAST(Y1 as varchar)+','+CAST(X2 as varchar)+','+CAST(Y2 as varchar)+')'
+'$shape'+ cast(ROW_NUMBER()OVER(ORDER BY (SELECT 0)) as varchar)+'.'+'linestyle="Gantt"'
+'$shape'+ cast(ROW_NUMBER()OVER(ORDER BY (SELECT 0)) as varchar)+'.'+'textstyle="Gantt"'+case when left(arrival, 2)='AC' THEN 'Red' ELSE '' END+ CASE WHEN LEFT(Departure, 2)='AC' THEN 'Red' ELSE '' END +' '+' '
---+'$shape'+ cast(ROW_NUMBER()OVER(ORDER BY (SELECT 0)) as varchar)+'.FillStyle="Gantt"'+CASE WHEN CHARINDEX()
+'$shape'+ cast(ROW_NUMBER()OVER(ORDER BY (SELECT 0)) as varchar)+'.Text="'+case when LEN(arrival)<>0 THEN Arrival ELSE '###' END +'/'+ [ACType Iata]+'/'+ CASE WHEN LEN(Departure)<>0 THEN Departure ELSE '###' END +'"'
+'$shape'+ cast(100+ROW_NUMBER()OVER(ORDER BY (SELECT 0)) as varchar)+'=$page.DrawLine('+cast(X1 -0.5 as varchar)+','+cast(Y1 -0.03 as varchar)+','+cast(X1 +0.5 as varchar)+','+cast(Y1 -0.03 as varchar)+ ')'
+'$shape'+ cast(100+ROW_NUMBER()OVER(ORDER BY (SELECT 0)) as varchar)+'.Text="'+CONVERT(char(5), [Allocation Start Datetime], 108)+'"'
+'$shape'+ cast(100+ROW_NUMBER()OVER(ORDER BY (SELECT 0)) as varchar)+'.TextStyle="Times"'
+'$shape'+ cast(100+ROW_NUMBER()OVER(ORDER BY (SELECT 0)) as varchar)+'.LineStyle="Times"'
+'$shape'+ cast(200+ROW_NUMBER()OVER(ORDER BY (SELECT 0)) as varchar)+'=$page.DrawLine('+cast(X2 -0.1 as varchar)+','+cast(Y1 -0.03 as varchar)+','+cast(X1 +0.1 as varchar)+','+cast(Y1 -0.03 as varchar)+ ')'
+'$shape'+ cast(200+ROW_NUMBER()OVER(ORDER BY (SELECT 0)) as varchar)+'.Text="'+CONVERT(char(5), [Allocation End Datetime], 108)+'"'
+'$shape'+ cast(200+ROW_NUMBER()OVER(ORDER BY (SELECT 0)) as varchar)+'.TextStyle="Times"'
+'$shape'+ cast(200+ROW_NUMBER()OVER(ORDER BY (SELECT 0)) as varchar)+'.LineStyle="Times"'
+'$shape'+ cast(300+ROW_NUMBER()OVER(ORDER BY (SELECT 0)) as varchar)+'=$page.DrawLine('+cast(X1 as varchar)+','+cast(Y2 as varchar)+','
FROM GanttReports(default,default)
GanttReport
是一个存储过程。输出将在一个大字符串中生成所有内容,例如
$shape1=$page.DrawRectangle(42.666660,6.78,58.083330,7.025)$shape1.linestyle="甘特图"$shape1.textstyle="甘特图" $shape1.Text="QK8718/DH1/QK8749"$shape101=$page. DrawLine(42.166660,6.75,43.166660,6.75)$shape101.Text="16:21"$shape101.TextStyle="Times"$shape101.LineStyle="Times"$shape201=$page.DrawLine(57.983330,6.75,42.766660, 6.75)$shape201.Text="17:30"$shape201.TextStyle="Times"$shape201.LineStyle="Times"$shape301=$page.DrawLine(42.666660,7.025)
但是我想要的是在单独的行中。你可以说使用'$shape'作为分隔符来分割它吗?
我知道我可以在论坛中搜索时创建拆分功能,但是不知道在这种情况下如何使用它。我是 SQL Server 的新手,如果有人可以提供帮助,我将不胜感激!