DECLARE @computername nvarchar(100) SELECT @computername = HOSTNAME() DECLARE…
- User
DECLARE @computername nvarchar(100) SELECT @computername = HOST_NAME() DECLARE @computeruser nvarchar(100) = ISNULL(OBJECT_NAME(@@PROCID), 'DAEX')
INSERT INTO _tblMatGroup ( T023_MATKL, T023_WGBEZ60, createcomputer, createuser, createdate, modifycomputer, modifyuser, modifydate ) SELECT ( T023_MATKL, T023_WGBEZ60, @computername, -- createcomputer - nvarchar(50) @computeruser, -- createuser - nvarchar(50) GETDATE(), -- createdate - datetime @computername, -- modifycomputer - nvarchar(50) @computeruser, -- modifyuser - nvarchar(50) GETDATE() -- modifydate - datetime)
from DUMP_TO_DB_MATGRP )
- Assistant
There is an error in the SQL statement. The closing parenthesis after 'GETDATE()' should be removed. The correct statement is as follows:
DECLARE @computername nvarchar(100) SELECT @computername = HOST_NAME() DECLARE @computeruser nvarchar(100) = ISNULL(OBJECT_NAME(@@PROCID), 'DAEX')
INSERT INTO _tblMatGroup ( T023_MATKL, T023_WGBEZ60, createcomputer, createuser, createdate, modifycomputer, modifyuser, modifydate ) SELECT T023_MATKL, T023_WGBEZ60, @computername, -- createcomputer - nvarchar(50) @computeruser, -- createuser - nvarchar(50) GETDATE(), -- createdate - datetime @computername, -- modifycomputer - nvarchar(50) @computeruser, -- modifyuser - nvarchar(50) GETDATE() -- modifydate - datetime
FROM DUMP_TO_DB_MATGRP
- User
correct this SQL query
- Assistant
DECLARE @computername nvarchar(100) = HOST_NAME() DECLARE @computeruser nvarchar(100) = ISNULL(OBJECT_NAME(@@PROCID), 'DAEX')
INSERT INTO _tblMatGroup ( T023_MATKL, T023_WGBEZ60, createcomputer, createuser, createdate, modifycomputer, modifyuser, modifydate ) SELECT T023_MATKL, T023_WGBEZ60, @computername, -- createcomputer - nvarchar(100) @computeruser, -- createuser - nvarchar(100) GETDATE(), -- createdate - datetime @computername, -- modifycomputer - nvarchar(100) @computeruser, -- modifyuser - nvarchar(100) GETDATE() -- modifydate - datetime FROM DUMP_TO_DB_MATGRP
- User
explane rhis codw
- Assistant
This SQL code is used to insert data into the
_tblMatGrouptable from theDUMP_TO_DB_MATGRPtable.- The variables
@computernameand@computeruserare declared and assigned values using theHOST_NAME()andISNULL()functions respectively. - The
INSERT INTOstatement is used to specify the target table and the columns in which data will be inserted. - The
SELECTstatement is used to retrieve data from theDUMP_TO_DB_MATGRPtable and populate the specified columns in the target table. - The
@computername,@computeruser, andGETDATE()functions are used to provide values for thecreatecomputer,createuser,createdate,modifycomputer,modifyuser, andmodifydatecolumns. - The code block is ended with a closing parenthesis and the
FROMkeyword is used to specify the source table for data retrieval.
This code will insert records into from the table, with additional information about the computer and user who performed the insertion, as well as the timestamps for the creation and modification of the records.
- The variables