Question: Trying to insert records from one table into another. The destination table (@TableName) has three extra columns than the source table (@Sourcetable). These three columns are float columns and are set to NULL. 

It doesn't matter if a zero is inserted or the NULL is left as is, as long as the insert works

The procedure fails because of that and gives the following error

> 
> Column name or number of supplied values does not match table
>  definition.
> 
> 
> 

See procedure below, any comments how I can do this with the procedure below:

```
ALTER PROCEDURE [dbo].[usr_INSERTRECORD]
    -- Add the parameters for the stored procedure here
    @SourceTable SYSNAME,
    @TableName SYSNAME,
    @TransDate Date,
    @Symbol nvarchar(50)
    --<@Param2, sysname, @p2> <Datatype_For_Param2, , int> = <Default_Value_For_Param2, , 0>
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for procedure here
    DECLARE @DATEVARCHAR nvarchar(4000);
    SET @DATEVARCHAR = CONVERT(NVARCHAR, @TransDate, 103);

-- Actual Statement that does the insert
-- This is the statement causing the issue; works if schema matches on both tables      
DECLARE @SQLCommand NVARCHAR(MAX) = 
            N'INSERT INTO ' + QUOTENAME(@TableName) + ' SELECT * FROM ' + + QUOTENAME(@SourceTable) 
            + ' WHERE (TRANSDATE = @TransDate AND SYMBOL = @SYMBOL)';

EXECUTE [dbo].[sp_executesql]  @sqlCommand,
                               N'@TransDate date, @Symbol nvarchar(50)',
                               @TransDate = @TransDate, @Symbol = @Symbol;
END

```

Answer: 
You cannot use the asterisk to include all fields if the table definitions are not identical:

You must use something like

```
INSERT INTO table1 (col1, col2, col3, ...) SELECT col1, col2, col3, ... FROM table2

```

As you are trying to fill the tables generically you could try to create their column lists like this

```
SELECT STUFF(
(
SELECT ',' + QUOTENAME(COLUMN_NAME) 
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE TABLE_NAME='YourTableName'
FOR XML PATH('')),1,1,'')

```

This column list you have to include into your statement...
If you don't have the same columns, then you have to explicitly list them. If the target table has more, then you can just list them in the insert side, if source table has more, then in the select, but best would be to list them in both.

You can also use views for both select and insert, so that the number of columns will match, but anyhow having insert + select \* without specifying columns isn't something that I would recommend, because it will break if someone adds new columns into the tables.