0

I have just created this table:

create table dbo.OrderTypes
(
ID smallint primary key identity,
Name varchar(300) not null,
CreatedOn datetime default getdate(),
CreatedBy nvarchar(300) not null,
ModifiedOn datetime default getdate(),
ModifiedBy nvarchar(300) not null
)

What I am trying to do is populate the Name field with results from this query:

select distinct ordertype from unit_results

as well as inserting CreatedBy and ModifiedBy by hand (they will be the same for every row).

How might I go about doing this?

1
  • I would suggest that you default the CreatedBy and ModifiedBy columns to something like system_user. Then you won't have to supply those values when a row is created. Commented Jul 5, 2012 at 21:19

1 Answer 1

2
INSERT INTO dbo.OrderTypes (Name, CreatedBy, ModifiedBy)
SELECT DISTINCT ordertype, 'CreatedBy Value Here', 'ModifiedBy Value Here'
FROM unit_results
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.