question

anees avatar image
anees asked

i have a sql 2008 db, i want to take the script of a single table in it. the table has over 10lakh datas, but i need to make scipt of first 1000 data only. how to do it?

i have a sql 2008 db, i want to take the script of a single table in it. the table has over 10lakh datas, but i need to make scipt of first 1000 data only. how to do it?
sql-server-2008
4 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

James_Chandler avatar image James_Chandler commented ·
I think it is a measurment unit equal to 100,000???
2 Likes 2 ·
GPO avatar image GPO commented ·
What's a lakh?
0 Likes 0 ·
@SQLShark avatar image @SQLShark commented ·
A lakh or lac is a unit in the South Asian numbering system equal to one hundred thousand (100,000; Scientific notation: 105).
0 Likes 0 ·
James_Chandler avatar image James_Chandler commented ·
At a risk of over simplifying your question, are you looking for this? SELECT TOP 1000 * FROM [DB_NAME_HERE]
0 Likes 0 ·

1 Answer

·
ThomasRushton avatar image
ThomasRushton answered
There are a few options; unfortunately, not all of them are free of charge. 1. SSMS itself will generate INSERT scripts for complete tables; admittedly, this doesn't exactly help your situation, but if you use a SELECT TOP 1000 * INTO <newtable>... you can then navigate to the table in SSMS's object explorer, right click, generate scripts, and in the dialog that that brings up is the option to script out the data as well as generate a "CREATE TABLE" script. 2. Mladen Prajdic has written the [SSMS Tools Pack][1] (free for SQL2008R2 and before; not free for SQL2012 and later). One of the features is an [Insert Statement Generator][2], that works on tables, views, and SSMS result sets (it's an option on the right-click menu) 3. Certain other SQL clients allow this - eg SQL Squirrel, TOAD, WinSQL; however, these are all likely to be more expensive options. [1]: http://www.ssmstoolspack.com/ [2]: http://www.ssmstoolspack.com/Features?f=9
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.