I have a very large number of records that must be inserted into a SQL Server database. It is about 1 million record that must be inserted.
I do so by running this simple bat script:
ECHO %TIME%
sqlcmd -S "SQLSERVER" -i "C:\Users\name\Desktop\OutPut\Result
tblAccount.sql"
ECHO %TIME%
Pause
But once I run the script I get the following error:
some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries
Is there any solution to how to insert that many records?
I have SQL Server 2014 Developer edition.
Edit the question by adding the query I'm running
IF NOT EXISTS (SELECT * FROM [dbo].[tblAccount]
WHERE [AccountID] = 117242
AND [TimeStamp] = CAST(N'2013-01-16 05:53:50.490' AS DateTime))
BEGIN
INSERT INTO [dbo].[tblAccount] ([AccountID], [Name], [Comment],[IsMachine],
[UserID], [Prefix], [Action], [Initials],
[Name], [TimeStamp], [Reason], [Iscal])
VALUES (117242, 'blabla', 'The users project)', 1,
'val', 39, 'val', 'blabla',
'blabla', CAST(N'2013-01-16 05:53:50.490' AS DateTime), 'NORMAL', '0')
END
It seems this is related to a bug in 2012 (fixed in SP2) and 2014 (fixed in SP1) according to this connect item, https://connect.microsoft.com/sqlserver/feedback/details/805659/sql-statement-is-nested-too-deeply -