Simple Insert query question

zkosky

Board Regular
Joined
Apr 13, 2004
Messages
60
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!!
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,221,860
Messages
6,162,479
Members
451,769
Latest member
adyapratama

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top