我想在记录末尾显示预告片记录: 规范如下
预告片记录:
Field Name Length Begin End Type Mandatory/Optional Description
TYPE 2 1 2 AN M TR' = Trailer
RECORD COUNT 12 3 14 N M Record count not including Trailer Record
PROCESS DATE 8 15 22 N M (system date YYYYMMDD Format)
FILLER 278 23 300 AN M Space Filled
我将这个预告片记录显示在一个文本文件中,该文件中已有的记录有大约1500条记录。我不能在行结束时得到这个。我使用Count(*)和getdate()函数,但是当我通过批处理(.bat)文件运行它时,没有在文本文件中获取和输出。
答案 0 :(得分:0)
USE [st]
GO
/****** Object: StoredProcedure [dbo].[P_tnvin] Script Date: 10/10/2016 13:35:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[P_tnvin]
--@policyNum nvarchar(30)
/*,@effectiveDate nvarchar(8)
,@VIN nvarchar(25)
,@lname1 nvarchar(40)
,@middle1 nvarchar(40)
,@fname1 nvarchar(40)
,@address1 nvarchar(50)
,@city nvarchar(35)
,@state nvarchar(2)
,@zip varchar(5)*/
AS
BEGIN
SET NOCOUNT ON;
Create Table TmpTNVINInfo
(
VINRecord char(300)
)
INSERT INTO TmpTNVINInfo
SELECT
(
'VS'
+ '12610'
+ CONVERT(CHAR(30),LEFT(P.policyNum, 30))
+ CONVERT(CHAR(8),P.effectiveDate, 112)
+ CONVERT(CHAR(25),LEFT(V.VIN, 25))
+ CONVERT(CHAR(40),LEFT(I.lname1, 40))
+ ' '
+ CONVERT(CHAR(20),LEFT(I.middle1, 20))
+ CONVERT(CHAR(40),LEFT(I.fname1, 40))
+ ' '
+ ' '
+ CONVERT(CHAR(50),LEFT(I.address1, 50))
+ CONVERT(CHAR(35),LEFT(I.city, 35))
+ CONVERT(CHAR(2),LEFT(I.state, 2))
+ CONVERT(CHAR(5),LEFT(I.zip, 5))
+ ' '
)storedprocedure
FROM
[st].[dbo].[Policy] P
JOIN
[st].[dbo].[Auto] A
ON
P.policyID = A.policyID
JOIN
[st].[dbo].[Vehicle] V
ON
A.autoID = V.autoID
JOIN
[st].[dbo].[Insured] I
ON
P.insuredID = I.insuredID
WHERE
P.policyType = 1 --1=Auto
AND
P.status = 1 --1=Active
AND
P.policyNum NOT LIKE 'Q%'
END
/*SELECT * FROM TmpTNVINInfo
/****** Cleanup Temp Table *******/
DROP TABLE TmpTNVINInfo*/
这是我用来显示记录的代码。