how to wite a query to insert only 10 records into database by using C#.net
how to wite a query to insert only 10 records into database by using C#.net
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Akkiraju IvaturiPosted Aug 12, 2012, 10:42 PM
-- Option 1: Top with Select
INSERT INTO InsertTestValue (ID)
SELECT TOP (2) ID
FROM TestValue
GO
-- Option 2: Top with Insert
INSERT TOP (2) INTO InsertTestValue1 (ID)
SELECT ID
FROM TestValue
GO
Mukesh RawatPosted Aug 10, 2012, 2:44 AM
Scenario 1:- If you having another table from where you have to select data and insert into another table in sql ?
Insert into [yourtablename] from select top 10 * from [youranothertablename.]
Note :yourtablename & youranothertablename should be same else specify the column names.
Scenario 2:- If you having another database[sql/access/excel] from where you have to select data and insert into another table in sql using C# ?
Then :
Select data from another database and make a for loop which will insert 10 records only.
Jignesh TrivediPosted Aug 9, 2012, 11:34 PM
Can you please provide more info about your requirement?
like Data is comes from where?
are you use store procedure for same?
thx.