如何在sql server 2008,asp.net,c#中存储数学符号(如代数) [英] How to store mathematical symbole(like algebra ) in sql server 2008 ,asp.net , c#
本文介绍了如何在sql server 2008,asp.net,c#中存储数学符号(如代数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在sql server 2008,asp.net,c#中存储数学符号(如代数)以及如何从数据库中检索记录PLZ ANS ME
解决方案
SQL服务器支持列中的Unicode字符,您可以使用N'...'前缀进行查询。
也可以查看这个
retrive-and-store-mathematical-question-in-sqlserver2005 [ ^ ]
- --------- ---------表-------------------
创建 表 MATH(id int ,等式 varchar ( 1000 ))
insert MATH
选择 1 ,' POWER(x + 1,2)' UNION 所有 - (x + 1)^ 2
选择 2 ,' COS(x)' - Cosinus(x)
- ------------------ QUERY ------------------- 跨度>
声明 @ query nvarchar ( 1000 )
声明 @ Result Float
声明 @ id int
声明 @ x float
set @ x = 0。< span class =code-digit> 5
set @ id = 1
set @query =(选择等式来自 MATH where Id = 1)
set @ query = ' 选择ROUND(' + replace( @ query ,' x',CAST( @ x as varchar ( 50 ))+ ' 000')+ ' ,5)'
< span class =code-keyword> exec ( @ query )
- 结果----------------------
- (0.5 + 1)^ 2 = 2.2500
- -----------------------------
< span class =code-keyword> set @query =(选择等式来自 MATH 其中 Id = 2)
set @ query = 跨度> <跨度class =code-string>选择ROUND(' + replace( @ query ,' x',CAST( @ x as varchar ( 50 ))+ ' 000')+ ' ,5)'
exec ( @ query )
- 结果----------------------
< span class =code-comment> - cos(0.5)= 0,87758
- -----------------------------
How to store mathematical symbole(like algebra ) in sql server 2008 ,asp.net , c# AND how to retrive record from database PLZ ANS ME
解决方案
SQL Server supports Unicode characters in columns, and you can query using the N'...' prefix.
also check this
retrive-and-store-mathematical-question-in-sqlserver2005[^]
--------------------TABLE------------------- create table MATH(id int,equation varchar(1000)) insert MATH select 1,'POWER(x+1,2)' UNION ALL -- (x+1)^2 select 2,'COS(x)' -- Cosinus(x) --------------------QUERY------------------- declare @query nvarchar(1000) declare @Result Float declare @id int declare @x float set @x=0.5 set @id=1 set @query=(select equation from MATH where Id=1) set @query='select ROUND('+replace(@query,'x',CAST(@x as varchar(50))+'000')+',5)' exec(@query) --RESULTS---------------------- --(0.5+1)^2=2.2500 ------------------------------- set @query=(select equation from MATH where Id=2) set @query='select ROUND('+replace(@query,'x',CAST(@x as varchar(50))+'000')+',5)' exec(@query) --RESULTS---------------------- --cos(0.5)=0,87758 -------------------------------
这篇关于如何在sql server 2008,asp.net,c#中存储数学符号(如代数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文