I want to insert into Tables but error:
Msg 207, Level 16, State 1, Line 1 Invalid column name 'A'. Msg 207, Level 16, State 1, Line 1 Invalid column name 'B'.
My table names is : TBL_PriceKeyBoard Keyboard is variable and maybe hard or ram but TBL_Price is static.
Declare @sql as nvarchar(max)
Declare @TBL as nvarchar(max)
Declare @Name_Edit nvarchar(max)
Declare @Name1 as nvarchar(max)= N'B'
Declare @Price as nvarchar(max) = N'12'
Declare @NameTBL as nvarchar(max) = N'KeyBoard'
set @Name_Edit = N'A'
set @TBL = N'TBL_Price'+ @NameTBL
Set @sql = N'INSERT INTO [DB1].[dbo].'+quotename(@TBL) +'
(
[Name_Edit]
,[Name1]
,[Price]
)
VALUES
(
'+@Name_Edit+'
,'+@Name1+'
,'+@Price+'
)'
EXECUTE sp_executesql @sql