How to wite a query to insert only 10 records into database by using C#.net
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Jignesh TrivediRank #16 · 50.3K reputationPosted Aug 9, 2012, 7:34 PM EDT
Can you please provide more info about your requirement?
like Data is comes from where?
are you use store procedure for same?
thx.
Mukesh Rawat7 reputationPosted Aug 9, 2012, 10:44 PM EDT
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.
Akkiraju IvaturiRank #473 · 5.3K reputationPosted Aug 12, 2012, 6:42 PM EDT
-- 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