I have below text file having different words inside it:

My aim is to insert only 4 character words from the text file into a table variable which is @temp, using bcp command.
So, at the end, the table variable @temp will look like below:

I have below text file having different words inside it:

My aim is to insert only 4 character words from the text file into a table variable which is @temp, using bcp command.
So, at the end, the table variable @temp will look like below:

Create a table where you will store the data coming from your file:
create table import(WORDS nvarchar(100))
Import data from file with bcp into the table created in the first step:
bcp [test].[dbo].[import] in d:\test.txt -c -T
Declare @table variable:
declare @table table ([ID] int identity(1,1), WORDS nvarchar(100))
Insert into @table variable only words with length = 4:
insert into @table
select WORDS
from import
where len(WORDS) <= 4
Now @table variable contains this data: