Create several tables with automatically generated name

  • Hello All!

    I have a question about table creation. The big table has N number or records, I need to create several tables automatically and insert 50K records in each table. How to generate the table name?? I was trying to use string variable for table name but sure it didn't work. Any ideas?

    Thanks.

     

  • Yes, I have an idea. Don't do that. What is N, how much is that? 10 million? 100 million? Even that can still stay in one table.

    I don't like the idea of generating tables automatically, this is something you shouldn't do. Of course, you can create temp tables during some procedure etc., but creating permanent tables without anyone controlling the process?

    Anyway, if you insist on that, the only way to create such tables (and name them as necessary) would be to use dynamic SQL (write the code into a string parameter and then execute it using sp_executesql). But dynamic SQL has some weak points, so again consider whether you really need to do that.

  • Thank you! I don't like the idea of generating tables but this is due to third part software limitation.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply