Could not find anything related to this issue I am having, google only seems to return how to use the default keyword with INSERT INTO.. VALUES.
I have a table with the following columns:
| RecordBookID | Shop ID | Created | Expires |
|---|---|---|---|
| uniqueidentifier | int | datetime | datetime |
RecordBookID has a default constraint that uses newid() as the default
I can run the following with expected results:
insert into GoodsIn_Record_Books (RecordBookID, ShopID, Created, Expires)
values (default, 201, '2022-07-22 11:24:00.000', '2022-12-31 23:59:00.000')
| RecordBookID | Shop ID | Created | Expires |
|---|---|---|---|
| EA5CB534-1DC3-46FA-B4F4-8EE70B974956 | 201 | 2022-07-22 11:24:00.000 | 2022-12-31 23:59:00.000 |
However I want to insert into with data from another table like so:
insert into GoodsIn_Record_Books (RecordBookID, ShopID, Created, Expires)
select default, ShopID, '2022-07-22 11:24:00.000', '2022-12-31 23:59:00.000' from System_Shops
Where the default keyword uses the default value of RecordBookID
System_Shops table:
| ShopID | Name | ... |
|---|---|---|
| 201 | WEST BAY | ... |
| 202 | TUMMEL VALLEY | ... |
| ... | ... | ... |
Hopefully this makes sense, first post on here so apologies if it's wrong in any way.
Cheers