Florin M.
Florin M.

Reputation: 2169

SQL Server insert into same values for some columns

There is a table called : Rules

This table has PK: RuleID, HouseID, StartDate EndDate and Value.

I must insert the following entries for 350 HouseIds.

The entries must be looking like this:

RuleID            HouseId   StartDate     EndDate    Value
__________________________________________________________
1st id generated  1stId   2015-12-24   2015-12-25   0
2nd id generated  2ndId   2015-12-24   2015-12-25   0

and so on.. As you can see, only the HouseId is changing (I want to take it from the list, for all the 350 houseids I want to insert some entries having a specific value for startdate, enddate, value).

How can I achieve this?

Upvotes: 2

Views: 47

Answers (1)

André Kops
André Kops

Reputation: 2713

INSERT INTO Rules (HouseId, StartDate, EndDate, Value)
SELECT HouseId, '2015-12-24'. '2015-12-25', 0
FROM Houses

Upvotes: 3

Related Questions