How to populate a table with 5 million rows in MS SQL Server? -
i'm working on app should find 26-letter code in char(26) column out of 5,760,000 rows. need know how long it's going take. i'm using ms sql server 2012 express.
i have database has 1 table, mytable
:
idcolumn integer codecolumn char(26) dateandtimecolumn datetime
- column 'codecolumn' has index.
- idcolumn integer id.
- codecolumn has "00592098715648275649283746" format (this example).
- dateandtimecolumn timestamp.
i populate table data tests , find out how long going take answer database. don't know how write proper tsql statement populate table 5,760,000 rows. second column long. how can populate table table populated?
let's data should when use statement
select idcolumn, codecolumn, dateandtimecolumn mytable;
output:
1 00000000000000000000000001 2014-11-19 15:46:50.843 2 00000000000000000000000002 2014-11-19 15:46:54.310 3 00000000000000000000000003 2014-11-19 15:46:56.060
and on ... till 5,760,000 rows.
how can that?
;with numbers ( select top (5760000) idcolumn = convert(int, row_number() on (order s1.[object_id])) sys.all_objects s1 cross join sys.all_objects s2 cross join sys.all_objects s3 ) insert dbo.yourtable select idcolumn, right(replicate('0',26)+convert(varchar(26),idcolumn),26) codecolumn, getdate() dateandtimecolumn numbers;
Comments
Post a Comment