如何选择输入参数的数据类型,它们可以从nvarchar,int,date或从下拉列表中选择的字段名称依赖的任何有效数据类型中变化 [英] how to choose a datatype of input parameter they can vary from nvarchar,int,date or any valid datatype depands upon the selected field name from the dropdown
本文介绍了如何选择输入参数的数据类型,它们可以从nvarchar,int,date或从下拉列表中选择的字段名称依赖的任何有效数据类型中变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
需要动态创建过程或查询.
下拉列表中的动态表名称,字段则相同.
如何选择输入参数的数据类型,可以从nvarchar,int,date或从下拉列表中选择的字段名称依赖的任何有效数据类型中改变.
Need to create a procedure or query dynamically.
dynamic table name from a dropdown ,and the same for fields.
how to choose a datatype of input parameter they can vary from nvarchar,int,date or any valid datatype depands upon the selected field name from the dropdown.
create procedure field_search(@name nvarchar(255),@field1_name nvarchar(255),@field1_value nvarchar(255),@field2_name nvarchar(255),@field2_value nvarchar(255))
as begin
SELECT * from @name
WHERE (@field1_name LIKE '%@field1_value%') AND (@field2_name LIKE '%field2_value%')
end
预先感谢.. !!!
thanks in advance..!!!
推荐答案
使用sql_variant
数据类型,它可以保存除"text"之类的大多数SQL数据类型.然后,您可以将SQL_Variant_Property
函数用于变量的实际数据类型
Usesql_variant
datatype, it can hold most of the SQL datatypes except for the ones like ''text''. You can then useSQL_Variant_Property
function to the actual datatype of the variable
这篇关于如何选择输入参数的数据类型,它们可以从nvarchar,int,date或从下拉列表中选择的字段名称依赖的任何有效数据类型中变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文