By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,843 Members | 2,311 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,843 IT Pros & Developers. It's quick & easy.

Select/Insert/Update a column with out a header

P: 31
Hey all, i'm trying to add two columns and send them into a column field in another table.

But, i'm getting an error saying that my column doesn't have a header. Any suggestions on how into insert query results that are teh result of computations? TIA
Feb 2 '09 #1
Share this Question
Share on Google+
4 Replies

Expert 2.5K+
P: 2,878
Can you post what you have so far?

-- CK
Feb 2 '09 #2

P: 31
Expand|Select|Wrap|Line Numbers
  1.  select e1.position + e2.position
  2.   Into DP.dbo.CP
  3.   from DP.dbo.excelDp e1, DP.dbo.excelDp e2
  4.   where e1.char1 = e2.char1 and e1.char2 = e2.char2  and e1.account = 'xx5' and e2.account = 'xx3'
Msg 1038, Level 15, State 5, Line 2
An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Add a name or single space as the alias name.
the code returns a column. The first column is the result of the arithmetic operation but has no column name. I found a solution in my application code but it takes one full iteration through the data. It's not a big deal but I think that this might be a scenario i'll come across again and would like to learn. The SQL algorithms are about a bajagaziillion times faster than what I code.
Feb 2 '09 #3

Expert 2.5K+
P: 2,878
A column alias should solve your problem. Something like.

Expand|Select|Wrap|Line Numbers
  1. select e1.position + e2.position as NewColumnName
  2. Into DP.dbo.CP
  3. from DP.dbo.excelDp e1, DP.dbo.excelDp e2  where e1.char1 = e2.char1 and e1.char2 = e2.char2  and e1.account = 'xx5' and e2.account = 'xx3'
Happy Coding!

-- CK
Feb 2 '09 #4

P: 31
Brilliant. Thanks for the help!
Feb 3 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.