How to insert global variable @@version into a sql table? Here is the command i used insert into ( select @@version as server_version ) schema name - dbo --- EDIT: pulled these details up from the comments I think this is what i have declared in the table CREATE TABLE [dbo].[server_config]( [srvId] [int] IDENTITY(1,1) NOT NULL, [Hostname] [varchar](50) NOT NULL, [Environmnet] [varchar](10) NOT NULL, [Instance_Name] [varchar](100) NOT NULL, [server_version] [nvarchar](100) NOT NULL, [Total_Memory_MB] [int] NULL, [Sql_Memory_MB] [int] NULL, [CPU_cores] [int] NOT NULL, [Last_server_startup] [datetime] NOT NULL, Msg 213, Level 16, State 1, Line 45 Column name or number of supplied values does not match table definition. ---
The error message is telling you exactly what's wrong. Your table has about 9 columns and your query has less than that. Plus they aren't in the same order. The table and the query need to have the same number of columns with data types that either match or where the query result value can be implicitly converted to the datatype of the matching table column.
What issues are you having with it? You don't specify the table name so is that the problem? This works for me: CREATE TABLE #insertTest (sqlVersion VARCHAR(200)) INSERT INTO #insertTest (sqlVersion) SELECT @@VERSION SELECT * FROM #insertTest