Author |
Topic |
infodemers
Posting Yak Master
183 Posts |
Posted - 2008-10-29 : 10:59:47
|
Hi I try To add the columns D + E + F and display the result in column CI run this update query to do it.UPDATE Table_Name SET C = isnull([D],0) + isnull([E],0) + isnull([F],0)Where = 'GWC'I get that little * as result, Any idea? [b] A B C D E F ABCDEF GWC * 553 371 0 GHIJKL GWC * 381 375 0 MNOPQR GWC * 358 482 0 STUVWX GWC * 14 70 0 Thanks! |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-29 : 11:22:49
|
what are the datatypes of C,D,E & F? |
 |
|
infodemers
Posting Yak Master
183 Posts |
Posted - 2008-10-29 : 11:28:32
|
The datatypes are all Integerquote: Originally posted by visakh16 what are the datatypes of C,D,E & F?
|
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-29 : 11:35:07
|
i dont think so. seems like C is varchar or char |
 |
|
infodemers
Posting Yak Master
183 Posts |
Posted - 2008-10-29 : 11:42:10
|
You are probably right, because my table is a temporary one.Should I convert the data fisrt before the addtion then?quote: Originally posted by visakh16 i dont think so. seems like C is varchar or char
|
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-29 : 12:10:02
|
can you post the structure of your table? you need to make sure C is of integer type if D,E,F are all integer |
 |
|
infodemers
Posting Yak Master
183 Posts |
Posted - 2008-10-29 : 12:24:45
|
My table is a temporary table and doesn't have any structure.To make sure the data types are okay, then I should create the temporary table and specify the type, right?UPDATE #Table_Name SET C = isnull([D],0) + isnull([E],0) + isnull([F],0)Where = 'GWC'quote: Originally posted by visakh16 can you post the structure of your table? you need to make sure C is of integer type if D,E,F are all integer
|
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-29 : 12:29:24
|
yup you should like belowCREATE TABLE #Table_name(..C int,D int,E int,F int,....) |
 |
|
infodemers
Posting Yak Master
183 Posts |
Posted - 2008-10-29 : 12:39:47
|
Give the man a cigar!Do you know if in SQL 2005 we also need to do the same?Thanks for your help!  quote: Originally posted by visakh16 yup you should like belowCREATE TABLE #Table_name(..C int,D int,E int,F int,....)
|
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-29 : 12:47:52
|
quote: Originally posted by infodemers Give the man a cigar!Do you know if in SQL 2005 we also need to do the same?Thanks for your help!  quote: Originally posted by visakh16 yup you should like belowCREATE TABLE #Table_name(..C int,D int,E int,F int,....)
yup..its same with sql 2005 also |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-10-30 : 04:12:25
|
See why you get *declare @d varchar(3)set @d=123*600print @dMadhivananFailing to plan is Planning to fail |
 |
|
|