zoukankan      html  css  js  c++  java
  • C#中 SQL语句

    SQL语句

    SELECT
    STUFF((
    (SELECT 
    ',{'
    +'"StructType":'+CONVERT(VARCHAR(1),ISNULL(hb.StructType,0))
    +',"IsCert":'+CONVERT(VARCHAR(1),ISNULL(hb.IsCert,0))
    +',"Area":'+CONVERT(VARCHAR(18),ISNULL(hb.Area,0))
    +'}'
    FROM ZSJTTD_HouseBuilding hb 
    WHERE hb.HouseID=h.ID AND hb.IsDeleted=0
    FOR XML PATH(''))),1,1,'' ) HouseBuildingInfo, 
    h.landPropertyOwner,h.CountAll,
    hh.Holder,hh.HolderIDcard,
    prj.landAssessPrice,prj.settlementCostPrice,prj.settlementPrice,prj.startSignDate,prj.NonHOuseSignAwardJSON,prj.NonHouseEmptyAwardJSON
    FROM 
    ZSJTTD_House h
    LEFT JOIN ZSJTTD_HouseHolder hh ON hh.id=h.holderID
    LEFT JOIN ZSJTTD_Project prj ON prj.ID=h.PrjID
    WHERE h.id='a83d70fa-0952-46aa-bd1d-2e5adca4c0b2'

    C#接口中:(转义字符的使用)

    string xml = string.Format(@"STUFF (((SELECT ',{{'+'""StructType"":'+CONVERT(VARCHAR(1),ISNULL(hb.StructType,0))"
                                           +@"+ ',""IsCert"":' + CONVERT(VARCHAR(1), ISNULL(hb.IsCert, 0))"
                                           +@"+ ',""Area"":' + CONVERT(VARCHAR(18), ISNULL(hb.Area, 0))"
                                           +"+'}}' "
                                           +@" FROM ZSJTTD_HouseBuilding hb
                    WHERE hb.HouseID = h.ID AND hb.IsDeleted = 0
                    FOR XML PATH(''))),1,1,'' ) HouseBuildingInfo");
    

    string sql = string.Format(@"SELECT {0}, h.landPropertyOwner,h.CountAll, hh.Holder,hh.HolderIDcard, prj.landAssessPrice,prj.settlementCostPrice,prj.settlementPrice,prj.startSignDate,prj.NonHOuseSignAwardJSON,prj.NonHouseEmptyAwardJSON FROM ZSJTTD_House h LEFT JOIN ZSJTTD_HouseHolder hh ON hh.id = h.holderID LEFT JOIN ZSJTTD_Project prj ON prj.ID = h.PrjID WHERE h.id = '{1}'", xml, HouseId);
  • 相关阅读:
    织梦开发——相关阅读likeart应用
    织梦标签教程
    织梦专题调用代码
    HIT 2543 Stone IV
    POJ 3680 Intervals
    HIT 2739 The Chinese Postman Problem
    POJ 1273 Drainage Ditches
    POJ 2455 Secret Milking Machine
    SPOJ 371 Boxes
    HIT 2715 Matrix3
  • 原文地址:https://www.cnblogs.com/dyhao/p/10345583.html
Copyright © 2011-2022 走看看