CREATE TABLE #tmpCustomers(
[CustomerID] [int] NOT NULL,
[CustomerCode] [varchar](20) NULL,
[CustomerName] [varchar](128) NULL,
[LeftCount] [int] NULL,
[RightCount] [int] NULL,
[CreationDate][datetime]null,
)
DECLARE Customer_Cursor CURSOR FOR
SELECT customerid
FROM Customers
OPEN Customer_Cursor;
declare @left int
declare @right int
declare @customerid int
FETCH NEXT FROM Customer_Cursor into @customerid
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC dbo.CountChildren @customerId,@left out,@right out
insert into #tmpCustomers
select customerId,[CustomerCode],[CustomerName],(CONVERT(NUMERIC(38,2), Creationdate)),@left,@right from Customers where CustomerID=@customerid
FETCH NEXT FROM Customer_Cursor into @customerid;
END;
select *, case when leftcount>RightCount then RightCount else LeftCount end as Pairs from #tmpCustomers a
drop table #tmpCustomers
CLOSE Customer_Cursor;
DEALLOCATE Customer_Cursor;
ここにコードがあります。このコードは次のエラーを出しています:
メッセージ 8115、レベル 16、状態 2、行 24
式をデータ型 datetime に変換する算術オーバーフロー エラー。
設定方法を教えてください。