Question : SQL Insert into X Select wildcard

The code below works fine…

BUT, there are about 50 xaoFormID with a value that starts with ‘FDES’. I want to do an INSERT INTO to all xaoFormIDs that starts with ‘FDES’. How do I write a SQL statement like the code below and apply it to 50 instead of having to do it one at a time fifty times?

Also, to check if you are getting proper results are not, can I write a Select statement for the INSERT INTO and check the data first?

THANKS!
1:
2:
3:
4:
INSERT INTO FormDefinitions (xaoFormID , xaoControlName, xaoClassID, xaoType, xaoProperties, xaoCode)
SELECT 'FDESXSTR09', xaoControlName, xaoClassID, xaoType, xaoProperties, xaoCode
FROM FormDefinitions
WHERE xaoFormID like '%FSIPNIAG09%' and xaoControlName like 'chkpart'

Answer : SQL Insert into X Select wildcard

Here you go.

INSERT INTO FormDefinitions (xaoFormID , xaoControlName, xaoClassID, xaoType, xaoProperties, xaoCode)
SELECT X.xaoFormID, xaoControlName, xaoClassID, xaoType, xaoProperties, xaoCode
FROM FormDefinitions cross join (
  select DISTINCT xaoFormID from FormDefinitions
  WHERE xaoFormID like 'FDES%'
) X
WHERE FormDefinitions.xaoFormID like '%FSIPNIAG09%' and xaoControlName like 'chkpart'


Regards
Random Solutions  
 
programming4us programming4us