-2

In the past when I was given a csv there would be only a few thousand rows so I would just create a temporary table and then insert the needed values into the table. The problem here is that I was given a csv this time with over 80,000 rows and there is a maximum allowed number of inserting 1000 row values. In the past with a few thousand I would just do this 3 or 4 times and then union them to create a master temporary table. What can I do to get these csv IDs into my SQL server? Also I included what I was doing before to be clear. Also to note, I have limited access. Thanks!

EDIT: Limited access means that I don't have permission to use the bulk load statement. I hoping there was a around that. If not, I will have to just explain the situation.

CREATE TABLE ##Test(ID BIGINT);

INSERT INTO ##Test
VALUES
(21477217322),
(21479276022),
(21478037922)
;
Don Quixote
  • 145
  • 1
  • 8
  • Import the CSV- http://stackoverflow.com/questions/15242757/import-csv-file-into-sql-server – Andrew L Jan 19 '17 at 21:57
  • 1
    Possible duplicate of [Import CSV file into SQL Server](http://stackoverflow.com/questions/15242757/import-csv-file-into-sql-server) – C8H10N4O2 Jan 19 '17 at 22:01
  • I do not have permission to use the bulk load statement. I was hoping there was a way around it. I think this is something that I just need to tell them I can't do with my current access so give me more access or have someone else do it. Thanks. – Don Quixote Jan 19 '17 at 22:16
  • You don't need bulk load permissions for the answer that has been given. You just need insert permissions. – Martin Smith Jan 19 '17 at 22:30

1 Answers1

1

You don't have to use a table valued constructor. You can instead use UNION ALL and then there is no limitation. Just have your csv build you a string that looks like this.

SELECT 21477217322 UNION ALL
SELECT 21479276022 UNION ALL
SELECT 21478037922

Or an even simpler solution would be to use the data import tool and not do this manually.

Sean Lange
  • 33,028
  • 3
  • 25
  • 40
  • I tried to use the data import but it said my access was too limited. Thanks. – Don Quixote Jan 19 '17 at 22:00
  • 1
    Well if you are restricted from importing data there may well be a reason for that. I would get with your dba and ask about getting access for this type of thing so you can do your job. – Sean Lange Jan 19 '17 at 22:01
  • Haha. Yeah. That looks to be the case. I just thought I would throw out a hail mary to stack overflow. Appreciate the response. – Don Quixote Jan 19 '17 at 22:11