How to wite a query to insert only 10 records into the database in sql server
How to wite a query to insert only 10 records into the database in sql server
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:28 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 11, 2012, 10:45 AM
Here is your query :
I have tested this and is working.
naga jyothiPosted Aug 10, 2012, 9:14 PM
sg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'from'.
Query "insert into EmployeeDetailsMaster from (select top 10 EmpId,EmployeeName from EmployeeDetailsMaster)
Error comes sg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'from'.
Mukesh please rectify the error
Mukesh RawatPosted Aug 10, 2012, 2:30 AM