Note to self: It’s easy to import an entire file into SQL Server.
Given a table that looks like this:
CREATE TABLE [dbo].[TableWithLargeColumn]( [Id] [int] IDENTITY(1,1) NOT NULL, [Data] [nvarchar](max) NULL, CONSTRAINT [PK_TableWithLargeColumn] PRIMARY KEY CLUSTERED ( [Id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
You can insert a text file into the Data column like this:
insert into TableWithLargeColumn(Data) select BulkColumn FROM OPENROWSET (BULK N'C:\Users\public\testdata.txt', SINGLE_CLOB ) as Document