Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
not insert negative no in numeric datatype in sql server
in insert query
insert into dbo.printing_list(batch_code,bill_no,date,sr_no,gross_wt,core_wt,nett_wt,c_id,category,operator)

here gross_wt,core_wt,nett_wt should not be negative

and not update the data if updated value is negative
in update query
update dbo.raw_in_godown set godown_quantity=godown_quantity-some_no
here updated godown_quantity should not be negative
Posted
Comments
phil.o 3-Dec-13 4:36am    
Please show your c# code. And format it so that it is readable.
thatraja 3-Dec-13 4:52am    
Why this question? :( Logic of this answer could help you to achieve your thing.

1 solution

You can't do that in SQL directly: you can either check in your C# code and not issue the SQL command, or you can write SQL stored procedures to do the insert and update functions and check there. But there is no simple way to prevent SQL from storing negative numbers.
 
Share this answer
 
Comments
Abhijeet pratap singh 3-Dec-13 6:58am    
can you tell me how and what give in connection string for sql server
that the software run on each computer on creating msi file
OriginalGriff 3-Dec-13 7:11am    
No. Nobody can.
The connection string needs to have the name of the SQL server instance and the login details that the database user is going to use when he connects to SQL. Both of these willl change depending on how SQL is configured when it is installed, and there is no "one string" which will fit all circumstances.
Abhijeet pratap singh 3-Dec-13 7:18am    
then which database or technique i have to use that the software can run on each computer like other softwares iam developing software in c#.net
Abhijeet pratap singh 3-Dec-13 7:17am    
then which database or technique i have to use that the software can run on each computer like other softwares iam developing software in c#.net
OriginalGriff 3-Dec-13 7:29am    
That depends on what you need the database for: if you need it so that a single user can access it for example, it's completely different from if you need two or more people sharing the same data.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900