We help IT Professionals succeed at work.

Insert Using Both Fixed Values And Select Statement?

pointeman
pointeman asked
on
I would lke to Insert Into Secured: 0, LogDate,Messages. I'm currently doing this with 2 statements; Insert, then Update(not shown). I'm always looking for a shorter way to code.

[Current Insert NOT working!]
Insert Into Secured (IsDone,LogDate,Messages)
 0, (Select convert(varchar,convert(datetime,LogDate),22),Messages
 FROM Logs
 GROUP By LogDate,Messages)
Comment
Watch Question

try
Insert Into Secured (IsDone,LogDate,Messages)
 Select 0, convert(varchar,convert(datetime,LogDate),22),Messages
 FROM Logs 
 GROUP By LogDate,Messages

Open in new window

Author

Commented:
Excellent!