Reputation: 79
suppose in my table i have a field Normal for this field , i have to insert same value from row 1 to 100 ,how can i give with single query please tell me guys.
Upvotes: 0
Views: 64
Reputation: 925
The following will update the normal of the 1st 100 rows of your table based on the order by (I chose Id as generally this would be the 1st 100 rows added, other options are things like created date if your table does not have a primary key.)
Update yourtable
set Normal = xxxxxx
where ROW_NUMBER() OVER(ORDER BY ID) <= 100
This is more accurate than using
Id between 1 and 100
as that does not take into consideration deleted records from 'yourtable'.
Upvotes: 0
Reputation: 3027
INSERT INTO tbl_name
(normal)
VALUES
(value),(value),(value),(value),(value)
repeat value 100 times
Upvotes: 0
Reputation: 172528
You can try to use the Update query like this:
UPDATE mytable
SET myColumn = 'yourValue'
WHERE id BETWEEN 1 AND 100;
If you want to update
only the rows which have id between 1 and 100
then add a where
clause condition as well. And if it is for all the rows then you can remove the where
condition.
Upvotes: 1