Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Temp table - missing a command, error

Author  Topic 

scared
Starting Member

14 Posts

Posted - 2007-06-22 : 14:25:57
Here I am creating a temp table with $ summations that I can later join with an employees table that I'm dumping into a flat file.

select

e.employee_no,
sum(p.fit) as sumfit,
sum(p.fica) - sum(p.medicare) as sumfica,
sum(p.medicare) as sumedic,
sum(p.fit_earnings) as pearnings,
sum(p.fit_earnings) as tearnings

into #earntable

from employees as e
left outer join pay_summary as p on e.employee_no =p.employee_no

where e.employee_no = 817 and
dateadd(d, 0, datediff(d, 0, p.dated)) between '20061231'and '20070401'

group by e.employee_no

select * from #earntable

When I go to look at the contents of the #earntable with the above select, I get this:

ODBC error 214 Procedure expects parameter '@handle' of type 'int'.
(42000)

The datatypes I'm trying to select into the temp table are all
numeric 12 except employee_no char 10.

What am I missing? A drop table statement?

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-06-22 : 14:33:39
If employee_no is char
e.employee_no = 817 

should be
e.employee_no = '817' 


Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-06-22 : 14:35:17
And you might want to use varchar(10) instead of char(10). char padds the values with extra spaces to make it fixed width, which can also cause problems when querying because '817' will not be same as '817 '.


Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

cvraghu
Posting Yak Master

187 Posts

Posted - 2007-06-22 : 15:38:04
Can you provide complete picture? How/Where are you executing this - in Query analyzer? Is it part of SP?
Go to Top of Page

scared
Starting Member

14 Posts

Posted - 2007-06-22 : 16:45:41
quote:
Originally posted by cvraghu

Can you provide complete picture? How/Where are you executing this - in Query analyzer? Is it part of SP?



That is the complete picture: every word of code, not one more or one less. I fixed the select statement for the char employee_no, that's all. Not a stored procedure, just a query to try to create a temp table and then look at the contents afterwards.

Sigh.
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-06-22 : 16:54:56
Did fixing the employee_no give expected result?

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2007-06-22 : 16:57:04
quote:
Originally posted by scared

quote:
Originally posted by cvraghu

Can you provide complete picture? How/Where are you executing this - in Query analyzer? Is it part of SP?



That is the complete picture...


sigh...

Since you didn't even answer the question about how you are running it, the picture is not complete.



CODO ERGO SUM
Go to Top of Page
   

- Advertisement -