Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable usage inside insert statement

Status
Not open for further replies.

hedgracer

Programmer
Mar 21, 2001
186
US
I have the following code:


DECLARE @sYEARMO AS VARCHAR(8);
SET @sYEARMO = (SELECT max(Business_Date) FROM [Exchange_Rates_Entry_Table_Daily])
PRINT @sYEARMO

TRUNCATE TABLE [Exchange_Rates_Entry_Table_Monthly]

INSERT INTO [Exchange_Rates_Entry_Table_Monthly] (
[Currency_Name],
[Currency_Whole_Name],
[Exchange_Rate],
[Business_Date],
[Currency_Symbol]
) SELECT * FROM [Exchange_Rates_Entry_Table_Daily]
Business_Date = @sYEARMO

I have tried encasing @sYEARMO in '' with a + in front of the variagble and keep receiving errors. A search of this forum and Googling has produced no information that will lead me to solving this problem. Can someone help me with this problem? Any help is appreciated. Thanks.

Dave
 
Please ignore previous post. I discovered my mistake. 6 years of doing SQL and forgot a WHERE. Go figure. Sorry for wasting everyone's time.

Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top