日期:2014-05-18  浏览次数:20677 次

以下SQL语句,如何加入C#代码
以下是SQL查询分析器中调试通过的代码:
declare @name varchar(50)
select @name =b.name from sysobjects b join syscolumns a on b.id = a.cdefault 
where a.id = object_id('bj_gzbxz') 
and a.name ='L1'

我想把他转换成C#中代码,如果写,并得到 @name 中的值并复制给C#中变量

------解决方案--------------------
SQL code
create proc pro_test 
@name  varchar(50)output
as
select @name =b.name 
from sysobjects b join syscolumns a on b.id = a.cdefault  
where a.id = object_id('bj_gzbxz')  
and a.name ='L1'
go

------解决方案--------------------
SQL code

create proc pro_test 
(@name varchar(20) output)--忘了写类型
select @name =b.name 
from sysobjects b join syscolumns a on b.id = a.cdefault  
where a.id = object_id('bj_gzbxz')  
and a.name ='L1'
go