SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 temp tables
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

rjhe22
Posting Yak Master

233 Posts

Posted - 03/11/2013 :  07:23:55  Show Profile  Reply with Quote
hi
trying to get my info into a temp table. not sure if im doing it right.
DECLARE @FirstTable TABLE (RandomInteger nvarchar)
BEGIN
INSERT INTO @FirstTable
SELECT * FROM generic.DailyPrice
inner
join generic.Simulation
on generic.DailyPrice.ISIN =generic.Simulation.ISIN
where Date=
(SELECT MAX(Date) FROM generic.DailyPrice)
end
go

getting this error
Column name or number of supplied values does not match table definition
any ideas

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 03/11/2013 :  07:28:03  Show Profile  Reply with Quote

DECLARE @FirstTable TABLE (RandomInteger nvarchar)
BEGIN
INSERT INTO @FirstTable
SELECT column corresponding to randominteger field
FROM generic.DailyPrice 
inner
join generic.Simulation
on generic.DailyPrice.ISIN =generic.Simulation.ISIN
where Date=
(SELECT MAX(Date) FROM generic.DailyPrice)
end
go


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

rjhe22
Posting Yak Master

233 Posts

Posted - 03/11/2013 :  07:30:42  Show Profile  Reply with Quote
i dont have an actually table for it. i want to do it without creating a table. i no there is a way to d0 this right
Go to Top of Page

rjhe22
Posting Yak Master

233 Posts

Posted - 03/11/2013 :  09:32:45  Show Profile  Reply with Quote
have it like this now
DECLARE @FirstTable TABLE
(
  Fk_fund int,
  Date datetime,
  isin nvarchar,
  Fundname ntext,
  ShareCurrency nvarchar,
  Pricepershare numeric,
  exchanegRate numeric,
  FirstSimulation nvarchar,
  SecondSimulation nvarchar,
  ThirdSimulation nvarchar
)




    INSERT  INTO @FirstTable (Fk_fund, Date,isin,Fundname,ShareCurrency, Pricepershare,
    exchanegRate,FirstSimulation,SecondSimulation,ThirdSimulation)
SELECT dp.Fk_fund ,
  dp.Date ,
  dp.isin ,
  dp.Fundname,
  dp.ShareCurrency ,
 dp. Pricepershare ,
 dp. exchanegRate ,
  s.FirstSimulation ,
  s.SecondSimulation ,
  s.ThirdSimulation 
   FROM generic.DailyPrice dp
inner
  join generic.Simulation s
  on dp.ISIN =s.ISIN
where Date=
  (SELECT MAX(Date) FROM generic.DailyPrice)


getting this error
Msg 8152, Level 16, State 13, Line 21
String or binary data would be truncated.
The statement has been terminated.
Go to Top of Page

rjhe22
Posting Yak Master

233 Posts

Posted - 03/11/2013 :  10:11:49  Show Profile  Reply with Quote
got this working
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 03/11/2013 :  12:15:56  Show Profile  Reply with Quote
Make sure your varchar fields have enough length to hold the incoming data to avoid this error. Recommended approach is to keep the length same as that of source field from which you insert

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000