Home > Software design >  SQL Server - Add results of a SELECT query to an existing table
SQL Server - Add results of a SELECT query to an existing table

Time:02-11

I currently have a table in SQL Server called masterTable. What I'd like to do is to add a new column to this table called report_Date.

I would like to store the results of a SELECT query in the report_Date column. The query works fine (it converts a nvarchar into a desired date format). What I can't do is append the results to the column.

My query:

SELECT 
    CONVERT(varchar(10), CAST(FileName AS date), 103) AS FileName 
FROM dbo.masterTable

Any suggestions please?

CodePudding user response:

If I understand your question correctly then

UPDATE dbo.masterTable SET
 report_Date = CONVERT(varchar(10), CAST(FileName as date), 103)
  • Related