临时 SQL 数据字段 [英] Temporary SQL datafield
问题描述
目前我正在返回一个布尔值作为1"或0"或列的值,比如我的存储过程之一中的列 A 并且它运行良好,但是在其中一个应用程序中我试图获得类似的值这个
Currently I am returning a boolean value as "1" or "0" or value of a column let say column A in one of my stored procedure and it works perfectly, however in one of application I am trying to get value like this
string temp = reader.TryGetValue("ColumnA", out licenseStatus) ? temp : string.Empty;
存储过程就是这样做的,
Stored procedure is doing something like this,
if @datafield = 1
return 1
else if @datafield = 2 AND @datafield2 = 3
return 0
else
return (SELECT ColumnA.table2 FROM table1 INNER JOIN table2 on table1.id and table2.id Where @datafield3 = 0)
现在我想始终将结果作为 ColumnA 的值返回,而不是发送0"或1",因为我不允许更改应用程序中的代码.
Now I want to return result as value of ColumnA always instead of sending "0" or "1" as I am not allowed to make changes to code in application.
有可能吗?我也根本无法对 ColumnA 值进行任何更改.
Is it possible ? I can't make any changes to ColumnA value at all either.
编辑
我已经在我的问题中提到存储过程正在做什么它假设可以但不使用我的代码,因为我返回 1 或0 在某个时候,我的代码没有把它作为 columnA 所以它的设置它是空的,我想返回 0 或 1 作为 ColumnA 的值,但同时时间我不想更改 table2 中 columnA 的值..
I already mentioned in my question that stored procedure is doing what its suppose to do but not working with my code, as I am returning 1 or 0 at some point and my code isn't getting it as columnA so its setting it up empty, I want to return 0 or 1 as value of ColumnA but at same time I don't want to change value of columnA in table2..
:)
推荐答案
if @datafield = 1
set ColumnA.table2=1
else if @datafield = 2 AND @datafield2 = 3
set ColumnA.table2= 0
else
return (SELECT ColumnA.table2 FROM table1 INNER JOIN table2 on table1.id and table2.id Where @datafield3 = 0)
如果它只是一个选择查询,那么它不会改变你的表数据,而是会返回你想要的
If it is only a select query then it will not change your table data rather it'll return what you want
这篇关于临时 SQL 数据字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!