我测试过没有问题的,确信你的程序数据库连接的事sql2005,因为这个语法2000是不支持的using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection()) { conn.ConnectionString = "server=xxx;pwd=***;uid=sa;database=tempdb"; conn.Open(); using (System.Data.SqlClient.SqlCommand command = conn.CreateCommand()) { command.CommandText = @"with ce1 as( select [dbo].[GetType]('2') as type,name from sysobjects ) select * from ce1 "; using (System.Data.SqlClient.SqlDataAdapter adp = new System.Data.SqlClient.SqlDataAdapter(command)) { System.Data.DataSet ds=new DataSet(); adp.Fill(ds); Console.WriteLine(ds.GetXml()); } } }
with ce1 as( select [dbo].[GetType]('2') as type,con1,con2 from myTable ) 你这是什么数据库的存储过程啊 不懂啊 改成 with ce1 as( select [GetType]('2') as type,con1,con2 from myTable ) 看看吧
{
conn.ConnectionString = "server=xxx;pwd=***;uid=sa;database=tempdb";
conn.Open();
using (System.Data.SqlClient.SqlCommand command = conn.CreateCommand())
{
command.CommandText = @"with ce1 as(
select [dbo].[GetType]('2') as type,name
from sysobjects
) select *
from ce1 ";
using (System.Data.SqlClient.SqlDataAdapter adp = new System.Data.SqlClient.SqlDataAdapter(command))
{
System.Data.DataSet ds=new DataSet();
adp.Fill(ds);
Console.WriteLine(ds.GetXml());
}
}
}
select [dbo].[GetType]('2') as type,con1,con2
from myTable
) 你这是什么数据库的存储过程啊
不懂啊
改成
with ce1 as(
select [GetType]('2') as type,con1,con2
from myTable
)
看看吧