I'm looking for suggestions on how to go about doing something that I am fairly certain that I should be able to do with SSIS.
I have two databases and I am updating Table B from Table A but as I do this I want to with ever successful write to Table B write some additional information to a log table back in the originating database. (See Illustration)
I'm not sure what control(s) I would use to accomplish this but suspect that it can be done inside of SSIS.
Use an OLEDB Transformation to do the UPDATE to table B, and then follow that with a Destination that writes to the log table.
After suggestions by Ivan Starostin and others on the board, I've opt'd to abandon using SSIS for doing this process and use stored procedures called from the code behind in the web page to perform this functionality. I'm including example of the insert process SP below as I'm working on the remainder but would like to close this question. Thanks to Ivan and all for your input. SSIS simply wasn't the best tool for this situation. It was much cleaner using SP as I found out.
USE [CInTracDB]
GO
/******** Object: StoredProcedure [dbo].[usp_InsertNewAssets] Script Date: 12/15/2016 3:00:00 PM *****/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Ken Carter>
-- Create date: <Dec 15, 2016>
-- Description: <Input Fields from Updates table, Insert all NEW records into CMDB.dbo.cmdb_assets, then copy record from
-- Updates to CInTracDB.dbo.Update_log, then Delete Record from Updates,
-- Return only sucesss / fail signal.
-- =============================================
CREATE PROCEDURE [dbo].[usp_InsertNewAssets](
#CAssetID as bigint,
#SubmitBy as varchar(50),
#SubmitDT as datetime,
#ApproveBy as varchar(50),
#Approved as char(10),
#ApprovedDT as datetime,
#Imported as char(10),
#ImportDT as datetime,
#AssetID as bigint,
#AssetType as int,
#AssetName as varchar(128),
#AssetShortDesc as varchar(50),
#AssetLongDesc as varchar(200),
#AssetAddNotes as varchar(254),
#AssetManuf as varchar(50),
#AssetModel as varchar(50),
#AssetTag as varchar(20),
#AssetAcqDate as datetime,
#AssetDTAssetID as varchar(20),
#AssetLocGrp as varchar(10),
#AssetLoc1 as varchar(8),
#AssetLoc2 as varchar(8),
#AssetLoc3 as varchar(8),
#AssetParent as bigint,
#AssetStatus as int,
#AssetPropType as int,
#AssetPrimUser as varchar(20),
#AssetEntered as datetime,
#AssetEnteredBy as varchar(50),
#AssetOwner as varchar(50),
#AssetCompany as varchar(10),
#AssetPriIPAddr as varchar(15),
#AssetPriMACAddr as varchar(17),
#AssetPriOS as varchar(20),
#AssetPriOSSP as varchar(20),
#AssetNotes as varchar(500),
#AssetAdminGrp as varchar(100),
#AssetSerialNum as varchar(75),
#AssetOperType as int,
#AssetOperStatus as int
)
AS
BEGIN
SET NOCOUNT ON;
DECLARE #AssetFACL as bit = 0
DECLARE #AssetStatVer as bit = 0
BEGIN
INSERT INTO CMDB.dbo.cmdb_assets (AssetType, AssetName, AssetShortDesc, AssetLongDesc, AssetAddNotes, AssetManuf,
AssetModel, AssetTag, AssetAcqDate, AssetDTAssetID, AssetLocGrp, AssetLoc1, AssetLoc2, AssetLoc3, AssetParent,
AssetStatus, AssetPropType, AssetPrimUser, AssetEntered, AssetEnteredBy, AssetOwner, AssetCompany, AssetPriIPAddr,
AssetPriMACAddr, AssetPriOS, AssetPriOSSP, AssetNotes, AssetAdminGrp, AssetSerialNum, AssetOperType,
AssetOperStatus, AssetFACL, AssetStatVer)
SELECT AssetType, AssetName, AssetShortDesc, AssetLongDesc, AssetAddNotes, AssetManuf, AssetModel, AssetTag,
AssetAcqDate, AssetDTAssetID, AssetLocGrp, AssetLoc1, AssetLoc2, AssetLoc3, AssetParent, AssetStatus, AssetPropType,
AssetPrimUser, AssetEntered, AssetEnteredBy, AssetOwner, AssetCompany, AssetPriIPAddr, AssetPriMACAddr, AssetPriOS,
AssetPriOSSP, AssetNotes, AssetAdminGrp, AssetSerialNum, AssetOperType, AssetOperStatus
FROM Updates
WHERE AssetID > 0
END
BEGIN
Insert INTO Update_log (CAssetID, SubmitBy, SubmitDT, ApproveBy, Approved, ApprovedDT, Imported, ImportDT, AssetID,
AssetType, AssetName, AssetShortDesc, AssetLongDesc, AssetAddNotes, AssetManuf, AssetModel, AssetTag, AssetAcqDate,
AssetDTAssetID, AssetLocGrp, AssetLoc1, AssetLoc2, AssetLoc3, AssetParent, AssetStatus, AssetPropType,
AssetPrimUser, AssetEntered, AssetEnteredBy, AssetOwner, AssetCompany, AssetPriIPAddr, AssetPriMACAddr, AssetPriOS,
AssetPriOSSP, AssetNotes, AssetAdminGrp, AssetSerialNum, AssetOperType, AssetOperStatus)
SELECT AssetType, AssetName, AssetShortDesc, AssetLongDesc, AssetAddNotes, AssetManuf, AssetModel, AssetTag,
AssetAcqDate, AssetDTAssetID, AssetLocGrp, AssetLoc1, AssetLoc2, AssetLoc3, AssetParent, AssetStatus, AssetPropType,
AssetPrimUser, AssetEntered, AssetEnteredBy, AssetOwner, AssetCompany, AssetPriIPAddr, AssetPriMACAddr, AssetPriOS,
AssetPriOSSP, AssetNotes, AssetAdminGrp, AssetSerialNum, AssetOperType, AssetOperStatus
FROM Updates
WHERE AssetID > 0
END
BEGIN
DELETE FROM Updates
WHERE (AssetID > 0)
END
END
GO
Related
Can you help me with this stored procedure? My problem is: when I create an account, my stored procedure works perfectly, but when I create a second account in the table evidenta_stundenti_materii, my previous id of account gets doubled.
How many times does it insert when I create an account :
in tbl_utilizatori : once
in tbl_studenti: once
in tbl_evidenta_stundenti: the previous id and the current id are re-inserted when I create the 2nd account
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[insertAnewAccAndANewStudent]
(#email varchar(30),
#parola varchar(30),
#nume varchar(30),
#prenume varchar(30),
#adresa varchar(30),
#nrTelefon varchar(30),
#conectat bit,
#idRol int,
#idSpecializare varchar(30))
AS
BEGIN
INSERT INTO dbo.tbl_utilizatori (email, parola, nume, prenume, adresa, nr_telefon, conectat, id_rol)
VALUES (#email, #parola, #nume, #prenume, #adresa, #nrTelefon, #conectat, #idRol)
IF (#idRol = '1')
BEGIN
DECLARE #id_utilizator int = ##identity
INSERT INTO dbo.tbl_studenti
VALUES (#id_utilizator, #idSpecializare, '0', '1')
END
INSERT INTO dbo.[tbl.evidenta_stundeti_materii] (id_utilizator, id_materie, id_specializare)
SELECT a.id_utilizator, b.id_materie, a.id_specializare
FROM dbo.tbl_studenti a
INNER JOIN dbo.tbl_materii b ON a.id_specializare=b.id_specializare
WHERE a.id_specializare = #idSpecializare
END
Bad English, can provide ss for a better understand problem
I have to do this in SQL Server. Assume that I have 2 tables.
Based on parameters Name and Surname, I have to take PhysicianID from Table1.
After that I have to create new record using insert into stored procedure.
Something like this
CREATE PROCEDURE FIND_PHYSICIANID
#FirstName varchar(50),
#LastName varchar(50)
AS
BEGIN
DECLARE #PhysicianID int
SELECT #PhysicianID = PhysicianID
FROM Table1
WHERE FirstName = #FirstName AND LastName = #LastName
RETURN #PhysicianID
END
EXECUTE FIND_PHYSICIANID 'Kathlin','Jones'
CREATE PROCEDURE ADD_APPOINTMENT -- Create a new appointment
#AppointmentType VARCHAR(70), --Type of new appointment
#pAppointmentDate DATE, -- Date of new appointment
#aPhysicianID INT, --PhysicianID of requested physician (in this case during execution we will take value which we know-read from table for requested first and last name)
#apPatientID INT, --PatientID of chosen patient(let's say any from 1 to 14)
#aScheduleID INT, --ScheduleID, but here we have to take some ScheduleID for chosen PhysicianID (in this case during execution we will take value which we know-based on PHYSICIANID we may read value from table SCHEDULE)
#Status CHAR(1) -- Just Y or N
AS -- This "AS" is required by the syntax of stored procedures.
BEGIN -- Insert the new appointment
INSERT INTO [APPOINTMENT]([AppointmentType], [AppointmentDate],[aPhysicianID],
[apPatientID], [aScheduleID], [Status-Canceled])
VALUES (#AppointmentType, #pAppointmentDate, #aPhysicianID,
#apPatientID, #aScheduleID, #Status);
END;
EXECUTE ADD_APPOINTMENT 'Vaccinations', '2017-0831', '#PhysicianID', '12', '289', 'N'
You can get return id like this.
DECLARE #PhysicianID int
EXECUTE #PhysicianID = FIND_PHYSICIANID 'Kathlin','Jones'
you can use this param like this
EXECUTE ADD_APPOINTMENT 'Vaccinations','2017-0831', #PhysicianID, '12','289','N'
Presuming that the ability to find a physician is a common operation you could convert the FIND_PHYSICIANID stored procedure to a function and delay the lookup to within the consuming stored procedure that performs the operation.
create function [dbo].[FIND_PHYSICIANID]
(
#FirstName varchar(50),
#LastName varchar(50)
)
returns int
as
begin
declare #PhysicianId int
select #PhysicianID = PhysicianID
from dbo.Table1
where FirstName = #FirstName
and LastName = #LastName
return #PhysicianId
end
This will still keep the logic of finding a physician centralised but allow you to perform other actions and possibly validation if the only information you have available to you is the full name. Yes, it is more parameters but this is assuming the required parameters for the stored procedures are a manageable amount.
create procedure [dbo].[ADD_APPOINTMENT] -- Create a new appointment
#AppointmentType VARCHAR(70), --Type of new appointment
#pAppointmentDate DATE, -- Date of new appointment
#PhysicianFirstName varchar(50), -- // The first name of the physician
#PhysicianLastName varchar(50), -- // The last name of the physician
#apPatientID INT, --PatientID of chosen patient(let's say any from 1 to 14)
#aScheduleID INT, --ScheduleID, but here we have to take some ScheduleID for chosen PhysicianID (in this case during execution we will take value which we know-based on PHYSICIANID we may read value from table SCHEDULE)
#Status CHAR(1) -- Just Y or N
AS -- This "AS" is required by the syntax of stored procedures.
BEGIN -- Insert the new appointment
declare #aPhysicianID int
select #aPhysicianID = [dbo].[FIND_PHYSICIANID](#PhysicianFirstName, #PhysicianLastName varchar(50))
INSERT INTO [APPOINTMENT]([AppointmentType], [AppointmentDate],[aPhysicianID],
[apPatientID], [aScheduleID], [Status-Canceled])
VALUES (#AppointmentType, #pAppointmentDate, #aPhysicianID,
#apPatientID, #aScheduleID, #Status);
END
Alternatively, if it is desired to be separated and keep the existing stored procedure parameter signature then the previous answer that has the caller lookup the physician id via the stored procedure locally and then pass that parameter into the add appointment stored procedure should suffice your requirements.
As per the below pseudocode
Declare a variable for #physicianid of type int
Assign the #physicianid variable to the output of the FIND_PHYSICIANID stored procedure
Execute ADD_APPOINTMENT stored procedure with #physicianid variable as an input
I have 4 tables in SQL Server: AspNetUsers, CustomerFile, CustomerOption and LastPullRecords. Application uploads the customer records from an Excel file. This Excel file is converted into DataTable and then for each row of the DataTable this stored procedure is called.
There is a trigger applied on the CustomerFile table. In this stored procedure first we check if FirstName, LastName, StreetAddress, City, State and Zip are not changed, then update only officer details other wise update all details, set the action to update ('U') and that will send the record to third party next day. Second, if that customer is not present then add it and set the action as add ('A'). After that if available then we update two other tables based on customer records.
ALTER PROC [dbo].[InsertUpdateRecords]
(
#FullName NVARCHAR(50) =NULL,
#FirstName NVARCHAR(50) =NULL,
#LastName NVARCHAR(50) =NULL,
#StreetAddress NVARCHAR(50) =NULL,
#City NVARCHAR(50) =NULL,
#State NVARCHAR(50) =NULL,
#Zip INT =NULL,
#SSN NVARCHAR(50) =NULL,
#Email NVARCHAR(150) =NULL,
#OfficerEmail NVARCHAR(50) =NULL,
#OfficerId NVARCHAR(50)=NULL,
#OfficerName NVARCHAR(50) =NULL,
#Option NVARCHAR(50) =NULL,
#DownloadedFromFTP BIT =NULL,
#LastPullDate DATETIME=NULL
)
AS
BEGIN
DECLARE #IsActive BIT
DECLARE #FileID INT
DECLARE #CompanyId INT
SET #IsActive=1
--Get Company ID based on OfficerID
Select #CompanyId=CompanyId from AspNetUsers where Email=#OfficerEmail
select top (1) #FileID=cf.fileId from CustomerFile cf inner join AspNetUsers usr on usr.Id=cf.OfficerId where cf.SSN = #SSN and usr.CompanyId=#CompanyId order by cf.FileReceivedDate, cf.FileId desc
if ((#FileID<>'') or(#FileID is not null))
Begin
-- COMPARE IF ONLY OFFICER IS CHANGED
If EXISTS(select 1 from CustomerFile where FirstName=#FirstName and LastName=#LastName and StreetAddress=#StreetAddress and City=#City and State=#State and Zip=#Zip
and FileId=#FileID
)
BEGIN
UPDATE top (1) CustomerFile SET OfficerEmail=#OfficerEmail,
OfficerName=#OfficerName,Email=#Email,
----FileModifiedDate=GETDATE(),
DownloadedFromFTP=#DownloadedFromFTP,IsActive=#IsActive,OfficerId=#OfficerId
WHERE FileId=#FileID
END
Else
BEGIN
Update top (1) CustomerFile set FullName=#FullName, FirstName=#FirstName, LastName=#LastName, StreetAddress=#StreetAddress, City=#City,State=#State,Zip=#Zip,
OfficerEmail=#OfficerEmail,OfficerName=#OfficerName,Email=#Email,
--FileReceivedDate=GETDATE(),
FileModifiedDate=GETDATE(),DownloadedFromFTP=#DownloadedFromFTP,IsActive=#IsActive,Action='U'
where FileId=#FileID
END
End
Else
BEGIN
declare #IdentityOutput table ( ID int )
INSERT INTO CustomerFile(FullName,FirstName,LastName,StreetAddress,City,State,Zip,SSN,OfficerEmail,OfficerId,OfficerName,
FileReceivedDate,DownloadedFromFTP,IsActive,Action,Email
)
output inserted.FileId into #IdentityOutput
VALUES(#FullName,#FirstName,#LastName,#StreetAddress,#City,
#State,#Zip,#SSN,#OfficerEmail,#OfficerId,#OfficerName,
GETDATE(),#DownloadedFromFTP,#IsActive,'A',#Email)
select #FileID = (select ID from #IdentityOutput)
END
---------------------------------------------------------------------------
-- Set Option
---------------------------------------------------------------------------
if ((#Option<>'') or(#Option is not null))
Begin
if exists(select 1 from CustomerOption where CustomerFileID=#FileID)
Begin
Update CustomerOption Set Option=#Option where CustomerFileID=#FileID
End
else
Begin
Insert into CustomerOption (CustomerFileID, Option) values (#FileID, #Option)
End
End
---------------------------------------------------------------------------
-- Insert Last Pull if exist
---------------------------------------------------------------------------
if ((#LastPullDate<>'') or(#LastPullDate is not null) or CONVERT(varchar(10),#LastPullDate,101)!='01/01/1900')
Begin
if((#FileID<>'') OR (#FileID<>0))
Begin
if exists (Select * from LastPullRecords where CustomerId=#FileID and CompanyId=#CompanyId)
bEGIN
Update LastPullRecords
set LastPullDate=#LastPullDate,
IsSelfPull=1,
ModifiedDateTime=getdate()
where CustomerId=#FileID and CompanyId=#CompanyId
End
ELSE
Begin
iNSERT INTO LastPullRecords
(CompanyId,CustomerId,LastPullDate,IsSelfPull,IsRTS,CreatedDateTime)
values
(#CompanyId,#FileID,#LastPullDate,1,0,getdate())
End
End
end
END
Problem is that there could be thousands of records and this query will take very long time to upload all those records. For testing i uploaded only 10K records and it took 13 minutes.
I tried to send the DataTable as parameter, defining custom User Table Type for the datatable, using while loop , then cursor but all these experiments are not making any difference.
Please suggest any optimized way to upload these records so it take less time.
I think you can choose from two options, if you want to keep using .NET for this task:
use SqlBulkCopy to copy data into intermediate tables (may be you can write insert without intermediate table), then write one command to insert all new data and second command to update all changed data.
use Table-Valued Parameters instead of SqlBulkCopy and intermediate tables (if your MSSQL not less than 2012)
Note, that SqlBulkCopy can be slower than Table-Valued Parameters for small data sets, but faster for big data sets.
I created a stored procedure which works perfectly. In an effort to convert it to a function in order to output tables for being used in other code, I created a multi-statement function.
I cannot use temporary tables so i now declare them as table variables but i get the errors bellow. I tried everything i can imagine and searched but either i am not doing it right or its not supported.
Declaring 3 tables as variables (instead of temporary tables in procedure)
I keep getting this error:
Msg 137, Level 16, State 1, Procedure _SLA_report_funct, Line ...
Must declare the scalar variable "#SupCarsSche".
CODE below:
USE DatabaseName
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: xxxxxxxxxxx
-- Create date:
-- Description:
-- =============================================
ALTER FUNCTION dbo._SLA_report_funct
(
-- Add the parameters for the function here
#Interval varchar(20),
#Starting_Datetime_offset int = 0,
#Trip_or_Day varchar(4)
)
RETURNS
#Table_Var TABLE
(
-- Add the column definitions for the TABLE variable here
TrainNumber int,
SerDate datetime,
First varchar(50),
Last varchar(50),
CusCarNumber int,
Fleet varchar(5),
Scheduled_Car bigint,
Depart varchar(50),
DepartTime varchar(50),
Arrive varchar(50),
ArriveTime varchar(50),
NodeOD int,
Caption nvarchar(255),
Trip_Availability real,
Trp_Availability_Count real,
Duration int
)
AS
BEGIN
-- Fill the table variable with the rows for your result set
DECLARE #SupCarsSche table
(
TrainNumber int,
SerDate datetime,
First varchar(50),
Last varchar(50),
CusCarNumber int,
Fleet varchar(5),
Scheduled_Car bigint,
Depart varchar(50),
DepartTime varchar(50),
Arrive varchar(50),
ArriveTime varchar(50)
)
DECLARE #SQLTemp varchar(MAX)
INSERT #SupCarsSche
SELECT
vsch.TrainNumber,
vsch.SerDate,
vsch.First,
vsch.Last,
vsch. CusCarNumber,
vsch.Fleet,
vsch.CarNumber AS Scheduled_Car,
vsch.Depart,
vsch.DepartTime,
vsch.Arrive,
vsch.ArriveTime
FROM _viaschedule5 AS vsch
RIGHT JOIN _supported_cars as supc ON vsch.CarNumber=supc.CarNumber
WHERE
((#Interval='MONTH') AND (datediff(MONTH, CAST(vsch.SerDate as DATE),(CAST(GETDATE() as DATE)))=#Starting_Datetime_offset) AND
(vsch.CarNumber LIKE '73%' OR NOT (vsch.CusCarNumber='')))
OR
((#Interval='DAY') AND (datediff(DAY, CAST(vsch.SerDate as DATE),(CAST(GETDATE() as DATE)))=#Starting_Datetime_offset) AND
(vsch.CarNumber LIKE '73%' OR NOT (vsch.CusCarNumber='')))
DECLARE #TripAvail table
(
NodeID int,
Caption nvarchar(255),
Trip_Availability real,
Trp_Availability_Count real,
SerDate datetime,
TrainNumber int,
Scheduled_Car bigint,
DepartTime varchar(50),
ArriveTime varchar(50),
Duration int
)
INSERT #TripAvail
SELECT
Nodes.NodeID,
Nodes.Caption AS Caption,
AVG(ResponseTime_Detail.Availability) AS Trip_Availability,
COUNT(ResponseTime_Detail.Availability) AS Trp_Availability_Count,
#SupCarsSche.SerDate,
#SupCarsSche.TrainNumber,
#SupCarsSche.Scheduled_Car,
#SupCarsSche.DepartTime,
#SupCarsSche.ArriveTime,
CASE
WHEN
(Datediff(MINUTE,CAST(#SupCarsSche.DepartTime as TIME),CAST(#SupCarsSche.ArriveTime as TIME))>0)
THEN
Datediff(MINUTE,CAST(#SupCarsSche.DepartTime as TIME),CAST(#SupCarsSche.ArriveTime as TIME))
ELSE
CAST ((24*60)-(DATEPART(hour, #SupCarsSche.DepartTime) * 60) - (DATEPART(minute, #SupCarsSche.DepartTime) * 1)+
(DATEPART(hour, #SupCarsSche.ArriveTime) * 60) + (DATEPART(minute, #SupCarsSche.ArriveTime) * 1)AS INT)
END AS Duration
FROM #SupCarsSche
LEFT JOIN Nodes ON (#SupCarsSche.Scheduled_Car = Nodes.Coach_ID)
LEFT JOIN ResponseTime_Detail ON ((Nodes.NodeID=ResponseTime_Detail.NodeID) AND (
((ResponseTime_Detail.DateTime BETWEEN (#SupCarsSche.SerDate+#SupCarsSche.DepartTime) AND (#SupCarsSche.SerDate+#SupCarsSche.ArriveTime))AND #SupCarsSche.DepartTime<#SupCarsSche.ArriveTime) OR
((ResponseTime_Detail.DateTime BETWEEN (#SupCarsSche.SerDate+#SupCarsSche.DepartTime) AND (DATEADD(DAY,1,#SupCarsSche.SerDate+#SupCarsSche.ArriveTime)))AND #SupCarsSche.DepartTime>#SupCarsSche.ArriveTime )))
GROUP BY #SupCarsSche.TrainNumber,Nodes.NodeID,#SupCarsSche.SerDate,#SupCarsSche.Scheduled_Car,Nodes.Caption,
#SupCarsSche.DepartTime, #SupCarsSche.ArriveTime,
CASE WHEN (
Datediff(MINUTE,CAST(#SupCarsSche.DepartTime as TIME),CAST(#SupCarsSche.ArriveTime as TIME))>0)
THEN
Datediff(MINUTE,CAST(#SupCarsSche.DepartTime as TIME),CAST(#SupCarsSche.ArriveTime as TIME))
ELSE
CAST ((24* 60)-(DATEPART(hour, #SupCarsSche.DepartTime) * 60) - (DATEPART(minute, #SupCarsSche.DepartTime) * 1)+(DATEPART(hour, #SupCarsSche.ArriveTime) * 60) + (DATEPART(minute, #SupCarsSche.ArriveTime) * 1)AS INT)
END
RETURN
END
It looks like when I use table variables, I need to add
FROM #SupCarsSche AS SCSH
After that, I use SCSH everywhere instead of the variable name.
This seems to resolve the issue.
After executing this procedure, in my result set, I got only 2 fields, I could not trace out the bug. I got only Sl No and TypeofDocument in my resultset
My code:
IF OBJECT_ID('PrGetDetails') IS NOT NULL
DROP PROCEDURE PrGetDetails
GO
CREATE PROCEDURE PrGetDetails
AS
BEGIN
SET NOCOUNT ON;
DECLARE #ReportDetails TABLE(
SlNo INT,
TypeOfDocument NVARCHAR(150),
Supplier NVARCHAR(150),
CodeNo NVARCHAR(150),
ReceivedDate Date,
ST_C DECIMAL(20,2),
ST_D DECIMAL(20,2),
EC_C DECIMAL(20,2),
EC_D DECIMAL(20,2),
HC_C DECIMAL(20,2),
HC_D DECIMAL(20,2)
);
INSERT INTO #ReportDetails (SlNo,
TypeOfDocument,
Supplier,
CodeNo,
ReceivedDate,
ST_C,
ST_D,
EC_C,
EC_D,
HC_C,
HC_D)
values
(1,'A','S1','AAJF7LSD01','2014/04/04',4362.00,0.00,87.00,0.00,44.00,0.00),
(2,'B','S2','AAJFV87LSD1','2014/04/04',2520.00,0.00,50.00,0.00,25.00,0.00),
(3,'C','S3','AK6009T001','2014/04/08',10498.00,0.00,210.00,0.00,105.00,0.00),
(4,'D','S3','AJ6009LST1','2014/04/16',45723.00,0.00,914.00,0.00,457.00,0.00),
(5,'E','S4','AAKPK8983001','2014/04/16',171.00,0.00,3.00,0.00,2.00,0.00),
(6,'F','S5','AKIPM8938P001','2014/04/16',14952.00,0.00,299.00,0.00,149.00,0.00),
(7,'G','S6','AKIPM8938P001','2014/04/16',28849.00,0.00,577.00,0.00,288.00,0.00),
(8,'','S7','AABCA7375CST042','2014/04/23',60000.00,0.00,1200.00,0.00,600.00,0.00),
(9,'','S8','AABCA7375CST042','2014/04/23',1482.00,0.00,30.00,0.00,15.00,0.00),
(10,'','S8','AABCA7375CST042','2014/04/29',250800.00,0.00,5016.00,0.00,2508.00,0.00)
SELECT * FROM #ReportDetails
END
GO
Please go to your project folder, delete the xxxx.rdl.data file. Then retrieve the data again. As I tested with your procedure, it can return all fields and records properly.