Ok, I was up for 3 hours last night trying to figure this out, so if the answer is realy obvious ... I was tired.
I just need to set some local variables and then insert them into a table.
Here is the query:
--***********************************************
CREATE TABLE CFTable
(Num INTEGER IDENTITY
,Section INTEGER
,Sequence INTEGER
,SectionName CHAR(20)
,Description CHAR(40)
,Amt INTEGER)
DECLARE @sec int
DECLARE @seq int
DECLARE @secName char
DECLARE @Description char
DECLARE @Amt int
SET @sec = 1
SET @seq = 1
SET @secName = "Operating Activities"
SET @Description = "Net Income for February 2001"
SET @Amt = 999
INSERT CFTable(section, sequence, sectionName, Description , Amt)
VALUES(@sec, @seq, @secName, @Description, @Amt)
--*****************************************************
I get the following error when I run it:
ADO Error: Invalid column name 'Operating Activities'
Invalid column name 'Net Income for February 2001'
This is run on an Acces Project that connects to a local SQL Server.
Does this have something to do with the fact that Num is an IDENTITY? (I don't know how this differs from an AUTO NUMBER PRIMARY KEY)
I don't understand why I'm getting this because I'm not trying to make @secName the column name. I just want to enter that string as an attribute of the record I'm trying to insert.
If you have any links to goods sites showing different ways of doing an INSERT query, please let me know. I can't seem to find any good ones.
Thanks!!
I just need to set some local variables and then insert them into a table.
Here is the query:
--***********************************************
CREATE TABLE CFTable
(Num INTEGER IDENTITY
,Section INTEGER
,Sequence INTEGER
,SectionName CHAR(20)
,Description CHAR(40)
,Amt INTEGER)
DECLARE @sec int
DECLARE @seq int
DECLARE @secName char
DECLARE @Description char
DECLARE @Amt int
SET @sec = 1
SET @seq = 1
SET @secName = "Operating Activities"
SET @Description = "Net Income for February 2001"
SET @Amt = 999
INSERT CFTable(section, sequence, sectionName, Description , Amt)
VALUES(@sec, @seq, @secName, @Description, @Amt)
--*****************************************************
I get the following error when I run it:
ADO Error: Invalid column name 'Operating Activities'
Invalid column name 'Net Income for February 2001'
This is run on an Acces Project that connects to a local SQL Server.
Does this have something to do with the fact that Num is an IDENTITY? (I don't know how this differs from an AUTO NUMBER PRIMARY KEY)
I don't understand why I'm getting this because I'm not trying to make @secName the column name. I just want to enter that string as an attribute of the record I'm trying to insert.
If you have any links to goods sites showing different ways of doing an INSERT query, please let me know. I can't seem to find any good ones.
Thanks!!