May 28, 2012 at 5:10 am
I want to split a table into multiple table.
what I need is a stored procedure that print a code that goes like this
/*
SELECT TOP 50000 * INTO dbo.LR_TABLE_TEST_1 FROM LR_TABLE_TEST ORDER BY NEWID()
SELECT TOP 50000 * INTO dbo.LR_TABLE_TEST_2 FROM LR_TABLE_TEST WHERE guidsource NOT IN (
SELECT guidsource FROM LR_TABLE_TEST_1
) ORDER BY NEWID()
SELECT TOP 50000 * INTO dbo.LR_TABLE_TEST_3 FROM LR_TABLE_TEST WHERE guidsource NOT IN (
SELECT guidsource FROM LR_TABLE_TEST_1 UNION ALL
SELECT guidsource FROM LR_TABLE_TEST_2
) ORDER BY NEWID()
SELECT * INTO dbo.LR_TABLE_TEST_4 FROM LR_TABLE_TEST WHERE guidsource NOT IN (
SELECT guidsource FROM LR_TABLE_TEST_1 UNION ALL
SELECT guidsource FROM LR_TABLE_TEST_2 UNION ALL
SELECT guidsource FROM LR_TABLE_TEST_3
) ORDER BY NEWID()
*/
I have managed to make the first and second statement (SELECT TOP 50000 * INTO dbo.LR_TABLE_TEST_1 FROM LR_TABLE_TEST ORDER BY NEWID()
SELECT TOP 50000 * INTO dbo.LR_TABLE_TEST_2 FROM LR_TABLE_TEST WHERE guidsource NOT IN (
SELECT guidsource FROM LR_TABLE_TEST_1
) ORDER BY NEWID() )
what i need is how to insert a record into the third and succeding table which records are not in the previous table as shown above. and to select * records(not top 50000*) into the final table I am stock on this I need a help . thank you somuch
May 28, 2012 at 5:13 am
May 28, 2012 at 5:21 am
Im sorry . cause I think my first post does not explain very well of my problem. 🙁 I edited it and explain it much better now, I want a tored procedue that prints the above codes.. apologies , and thank you 🙂
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply