多行的sql语句写成一行
2级分类寻找根类
数据库结构如下:
classId int
className nvarchar(20)
parentClassId int
根据任意一个类id查找根类信息的sql语句:
declare @sid
select @sid = 2
declare @tid int
select @tid = parentclassid from productcatalog where classid = @sid
select * from productcatalog where classid = (case when @tid = 0 then @sid else (select classid from productcatalog where classid = @tid) end)
为了能在asp.net中执行,必须把上面的语句写成一行(一个字符串),其实很简单,只要把各行用空格连接起来就可以了。
我来说两句
1 楼 站长 发表于 2008-5-24 From IP: 125.31.196.17
终于解决了编码问题。留言回复正常。
作者主页:
2 楼 测试中文乱码问题 发表于 2008-5-24 From IP: 125.31.196.17
希望能够解决问题。
作者主页: