Ok guys here is what I going through, I have a parent table called [dbo].[FileMetaData] and a child table called [dbo].[Ref_FileType] which is a reference to the Parent table. In the child table I have just two columns, TypeId whis is FK in the Parent table and TypeDescription I want to popluate the TypeId column in the parent table [dbo].[FileMetaData], here is how is got the typeDescription in the child table
INSERT into [test].[dbo].[Ref_FileType] (TypeDescription)
( select Distinct RIGHT(s.FileName,4) from [test].[dbo].[FileMetadata]s
WHERE NOT EXISTS (SELECT * FROM [test].[dbo].[Ref_FileType] ))
example is
TypeID | Type Descritption
1 xlsx
2 txt
3 TCF
Now I want to popluate the parent table [dbo].[FileMetaData] with and allocated TypeIdin the child table [dbo].[Ref_FileType] also note that
I got the TypeDescription from the insert statement above. So what I want is to insert based on the last 4 char in the file name, and example
DataValidationRules.xlsx.
If you check it it is a FileMetaData, so if it Fileaname ends with xlsx. I want to populate all typeID for such file with 1, if it ends with txt =2 , e.t.c
Please Kindly give a clear answer.
Thanks.