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.
Author |
Topic |
shinelawrence
Starting Member
32 Posts |
Posted - 2013-03-11 : 08:01:24
|
Hi Everyone, I insert numeric values in DB. If it empty textbox then the query is simple,,..so i got error. How to do. Please tell the solution.Thanks In AdvancedLawce |
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2013-03-11 : 12:01:04
|
The code example below works , using the NULL into a numeric data type. The ideal situation is to check and handle this type of situation at the application level , create table #temp1(myname nvarchar(100),age NUMERIC)INSERT INTO #temp1select 'Kevin' , nullselect * from #temp1drop table #temp1Jack Vamvas--------------------http://www.sqlserver-dba.com |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-03-11 : 12:34:00
|
you need to determine as per your rules whether you want to populate NULL or 0 as value in those cases------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
shinelawrence
Starting Member
32 Posts |
Posted - 2013-03-12 : 00:30:26
|
thank you for ur kinldy reply.. If my texbox have empty value then it should be stored at backend as 0 or if my textbox has value then it should be store...my querey is:insert into tbl_name values(1500.25)if it's empty how to store 0... Please tell the solution...Thanks In AdvancedLawce |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-03-12 : 00:37:50
|
quote: Originally posted by shinelawrence thank you for ur kinldy reply.. If my texbox have empty value then it should be stored at backend as 0 or if my textbox has value then it should be store...my querey is:insert into tbl_name values(1500.25)if it's empty how to store 0... Please tell the solution...Thanks In AdvancedLawce
check for blanks and make it as 0 ie do something likeCASE WHEN @TextboxValue > '' THEN @TextboxValue ELSE 0 END@TextboxValue is parameter through which you pass the textbox entered value to database------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
shinelawrence
Starting Member
32 Posts |
Posted - 2013-03-12 : 00:50:32
|
ok...thank you... so i need to write stored procedure...Lawce |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-03-12 : 00:52:48
|
yep...its recommended. you can even handle it in adhoc sql though------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|