Insert into table without null values

Posted by Vinokanna under C# on 9/1/2013 | Points: 10 | Views : 784 | Status : [Member] | Replies : 2
This is my Grid structure
two ddl first year and location

Grp Name Apr May Jun Jul Aug Sep Oct Nov Dec Jan Feb Mar
FM .
PM
BM
MP

i have load the grp name via master table through selection of location
for that 12 months default shown zero. when i enter a value of April for first row only that value will save to detail table
for that year,location,Grpname april value only enter to table meanwhile table have grp id ,grp name,year,location ,target columns
grpid grpname from master year and location select through ddl,
for that target column only we save month value if zero in other colums not go to the table. if apr - year 201304 target only one row save to tbl
other colums and row zero value not go to table.
If any body know pls help thanks in advance.




Responses

Posted by: Bandi on: 9/2/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Did you have already data into above table with all group names and other columns as zero...
To insert value into specific month column, you should go ahead with UPDATE statement
UPDATE TableName

SET April = SomValue
WHERE Grp = 'YourGroupName'


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Vinokanna, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/2/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Hi,
You can replace DB NULL values with ZERO by using ISNULL( ColumnName, 0) or COALESCE( ColumnName, 0) while inserting into table itself..
Ex: For suppose value in the first argument is 123, ISNULL( 123, 0) gives you 123 ;
ISNULL( NULL, 0) gives you 0 (ZERO) in the case of first argument value NULL

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Vinokanna, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response