CTE 정렬방법

ms-sql 2010. 9. 10. 09:58


WITH List_CTE AS (
SELECT Convert(NVARCHAR(255), NWMGUID) AS Sort  
 ,N.No
 ,N.NWMGUID
 ,N.ParentID
 ,N.Depth
 ,N.Date
 ,N.TypeCD
 ,N.Title
 ,N.PGGUID
 ,N.ModifyDT
FROM TB_GIFT_NWMeeting N
WHERE NWMGUID = @NWMGUID
UNION ALL
SELECT Convert(NVARCHAR(255),RTRIM(pf.Sort) + Convert(NVARCHAR(255),ROW_NUMBER() OVER(ORDER BY N.No desc))) AS Sort --정렬할값을 만들어준다.
 ,N.No
 ,N.NWMGUID
 ,N.ParentID
 ,N.Depth
 ,N.Date
 ,N.TypeCD
 ,N.Title
 ,N.PGGUID
 ,N.ModifyDT
FROM TB_GIFT_NWMeeting N
INNER JOIN List_CTE pf
ON pf.NWMGUID  = N.ParentID
AND N.Active='Y'
)

SELECT L.Sort
 ,(Select COUNT(*) from TB_GIFT_NWMeeting N where N.ParentID = L.NWMGUID) as Count
 ,(SELECT COUNT(*)-1 FROM TB_GIFT_SKAttendant SK WHERE SK.Type ='A' AND SK.ParentID = L.NWMGUID  ) as UserCount
 ,(SELECT  TOP 1 tul.Name FROM dbo.TB_GIFT_SKAttendant sk
  LEFT OUTER JOIN CmnMgt.dbo.tb_User tu
  ON sk.UserID = tu.UserID
  AND sk.Type ='A'
  LEFT OUTER JOIN CmnMgt.dbo.tb_Userlang tul
  ON tu.UserID = tul.UserID AND tul.LangID =@Lang
 WHERE SK.ParentID = L.NWMGUID ORDER BY SK.SEQ ASC) AS UserName
 ,L.No
 ,L.NWMGUID
 ,L.ParentID
 ,L.Depth
 ,L.Date
 ,L.TypeCD
 ,CATEGORY_Name as Type
 ,L.Title
 ,L.PGGUID
 ,P.PGName
 ,CONVERT(VARCHAR(10), L.ModifyDT, 120) as ModifyDT
 FROM List_CTE L
LEFT OUTER JOIN CmnMgt.dbo.tb_Category cg
ON L.TypeCD = cg.CATEGORY_CODE 
LEFT OUTER JOIN TB_GIFT_Program P
ON L.PGGUID = P.PGGUID
WHERE ParentID is not null
ORDER BY Sort

ms-help://MS.SQLCC.v10/MS.SQLSVR.v10.ko/s10de_6tsql/html/27cfb819-3e8d-4274-8bbe-cbbe4d9c2e23.htm
6번 참고

Posted by 정광원
,
Posted by 정광원
,



사용방법
file.SaveAs(TempPath + "\\" + oriFileName);  //원본데이터 저장
param : 실제경록, 템프 경로, 이미지 이름, Thumbnail조정할 width, Thumbnail조정할 Height
GenerateThumbnail(TempPath + "\\" + oriFileName, TempPath, imgFileName, Width, Height);

     #region ### 이미지 정렬 및 저장 ###
        public static void GenerateThumbnail(string sImagePath, string sSavePath, string sSaveName, int iX, int iY)
        {
            using (System.Drawing.Image imgFull = System.Drawing.Image.FromFile(sImagePath))
            {
                System.Drawing.Imaging.ImageFormat ifFormat = imgFull.RawFormat;
                int iNewX;
                int iNewY;
                if (imgFull.Width > iX || imgFull.Height > iY)
                {

                    decimal dOrigWidth = imgFull.Width;
                    decimal dOrigHeight = imgFull.Height;


                    decimal dRatio;
                    if (iX / dOrigWidth < iY / dOrigHeight)
                    {
                        dRatio = iX / dOrigWidth;
                    }
                    else
                    {
                        dRatio = iY / dOrigHeight;
                    }
                    iNewX = Convert.ToInt32(dOrigWidth * dRatio);
                    iNewY = Convert.ToInt32(dOrigHeight * dRatio);
                }
                else
                {
                    iNewX = imgFull.Width;
                    iNewY = imgFull.Height;
                }
                using (System.Drawing.Bitmap imgOutput = new System.Drawing.Bitmap(imgFull, iNewX, iNewY))
                {
                    using (System.Drawing.Graphics gfxResizer = System.Drawing.Graphics.FromImage(imgOutput))
                    {
                        gfxResizer.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                        gfxResizer.DrawImage(imgFull, 0, 0, iNewX, iNewY);
                        imgOutput.Save(sSavePath + "/" + sSaveName, ifFormat);
                    }
                }
            }
        }
        #endregion

Posted by 정광원
,

신뢰할수있는 싸이트 추가일때문가능
http://junyong.pe.kr/98

'javascript' 카테고리의 다른 글

ajax 동기 비동기  (1) 2011.12.14
updatepanel에서 javscript 호출  (1) 2010.12.06
setInterval()  (1) 2010.10.26
textbox의 글자수 Check(Byte)  (3) 2010.09.09
updatePanel 사용시 javascript 재등록  (1) 2010.09.09
Posted by 정광원
,
Posted by 정광원
,

ms-sql 2008 설치

ms-sql 2010. 9. 9. 15:58

'ms-sql' 카테고리의 다른 글

SQL 서버의 잠금에 대한 고찰  (1) 2010.09.10
CTE 방식으로 게시판 List Data가져오기  (3) 2010.09.10
CTE 정렬방법  (0) 2010.09.10
프로시져에서 Identity값 Return하기  (1) 2010.09.09
value값 구분자 넣어서 자르기  (3) 2010.09.09
Posted by 정광원
,

- 호출하는 부분
public void ExcelDownClick(object sender, EventArgs e)
{

    Context.Items["itemname"] = "test"
    Server.Execute("ExcelDown.aspx", true);
}

- 호출되는 페이지에서 Context를 받음
string strSort = Convert.ToString(Context.Items["sort"]);


html코딩
<div id='ExcelContent' runat='server' style="display:">  //sever 컨트롤로 등록한다.
        <%=strExcelContent %>
    </div>

- div에 동적으로 표시
private void ExcelTabel(DataTable ExcelTable, string[] strExcelHeader, int nColspan, string strTitle)
        {
            StringBuilder sb = new StringBuilder();
            string strBackColor = Skcc.Configuration.SkccFxConfigManager.GetString("BackColor");
               
            sb.Append("<table>");
            sb.Append("<tr>");
            sb.Append("<th colspan=" + strExcelHeader.Length.ToString() + ">");
            sb.Append("<h2>" + strTitle + "</h2>");
            sb.Append("</th>");
            sb.Append("</tr><tr>");
            sb.Append("</tr>");
            sb.Append("</table>");

            sb.Append("<table border='1' style='border-bottom-width:1px; border-left-width:1px; border-right-width:1px; border-top-width:1px;'>");
            sb.Append("<tr>");
            for (int h = 0; h < strExcelHeader.Length; h++)
            {
                sb.Append("<th style='background-color:").Append(strBackColor).Append(";'  >");
                sb.Append(strExcelHeader[h]);
                sb.Append("</th>");
            }
            sb.Append("</tr>");
            for (int i = 0; i < ExcelTable.Rows.Count; i++)
            {
                sb.Append("<tr>");
                string strCount = string.Empty;
                for (int j = 0; j < nColspan; j++)
                {
                    if (ExcelTable.Columns[j].ColumnName.Equals("Country"))
                    {
                        string strValue = ExcelTable.Rows[i][j].ToString();
                        if (ExcelTable.Rows[i][j].ToString().Equals("Etc"))
                        {
                            strValue = Resources.GIFT.CM_Unknown;
                        }
                        sb.Append(" <td >");
                        sb.Append(strValue.Replace("\r\n", "<br/>"));
                        sb.Append(" </td>");
                    }else
                    {
                        sb.Append(" <td >");
                        sb.Append(ExcelTable.Rows[i][j].ToString().Replace("\r\n", "<br/>"));
                        sb.Append(" </td>");  
                    }
                }
                sb.Append("</tr>");

            }
            sb.Append("</table>");
           
            strExcelContent += sb.ToString(); 
        }


//엑셀로 변환함
private void ExcelDownLoad(string strTitle)
        {
            Response.Clear();
            string strFileName = HttpUtility.UrlEncode(strTitle);
            strFileName = strFileName.Replace("+", "%20");
            Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.xls", strFileName));
            Response.ContentType = "application/vnd.ms-excel";

            System.Web.HttpContext.Current.Response.Write("<meta http-equiv=Content-Type content=''text/html; charset=utf-8''>");
            //Response.ContentEncoding = System.Text.Encoding.GetEncoding("euc-kr");
            System.IO.StringWriter stringWriter = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);

            ExcelContent.RenderControl(htmlWriter);  //div 컨트롤에 Rendering함

            Response.Write(stringWriter.ToString());
            Response.End();
        }



'asp.net' 카테고리의 다른 글

asp.net 이벤트 호출 순서  (2) 2010.09.09
이미지 Thumbnail(크기조정)  (0) 2010.09.09
updatepanel 안에 Repeater사용  (2) 2010.09.09
javascript에서 dopostback 호출하기  (2) 2010.09.09
updatePanel 사용  (0) 2010.09.09
Posted by 정광원
,

var oldStr, oldCnt;

function checkByte(element, labelID, Count) {
    var onechar;

    var tcount = 0;
    for (k = 0; k < element.value.length; k++) {

        onechar = element.value.charAt(k);

        if (escape(onechar).length > 4) {
            tcount += 2;
        }
        else if (onechar == '\n') {
            tcount += 2;
        }
        else if (onechar != '\r') {
            tcount++;
        }
           
    }
    var Label = eval("document.getElementById('" + labelID+ "')");

    if (tcount > parseInt(Count, 10)) {
        Label.innerHTML = Count;
        element.value = oldStr;
        tcount = oldCnt;
        return false; ;
    }

    oldStr = element.value;
    oldCnt = tcount;

    Label.innerHTML = tcount;

    return true;
}
사용법
onkeyup="return checkByte(this,라벨ID,제한글자수);"

'javascript' 카테고리의 다른 글

ajax 동기 비동기  (1) 2011.12.14
updatepanel에서 javscript 호출  (1) 2010.12.06
setInterval()  (1) 2010.10.26
이미지 미리보기  (2) 2010.09.09
updatePanel 사용시 javascript 재등록  (1) 2010.09.09
Posted by 정광원
,


 $(document).ready(function () {

            SelectRow();
     });

    function SelectRow() {
        $("#allchk").unbind('click');
        $("#allchk").click(function () {
            var allbox = $(this).attr("checked");
            if (allbox == true) {
                $('table#rptbl tr td input:checkbox').each(function () {
                    $(this).attr("checked", "checked");
                });
            } else {
                $('table#rptbl tr td input:checkbox').each(function () {
                    $(this).attr("checked", "");
                });
            }
        });

    var rows = $("table#rptbl tr");
    if (rows && rows.length > 0) {
        $(rows).each(function (idx) {
            if (idx > 0) {
                var startIdx = 1;
                var endIdx = rows[idx].childNodes.length;

                for (i = startIdx; i <= endIdx; i++) {
                    //$(rows[idx].childNodes[i]).click(function () {
                    $(rows[idx]).find('td').eq(i).unbind('click');
                    $(rows[idx]).find('td').eq(i).click(function () {
                        var ID = $(rows[idx]).find('td').eq(0).children('input[type="checkbox"]').val();          //GUID
                        alert("checkbox value : " + ID);
                        //ID 값을 넘겨서 ViewPage를 호출한다.
                    });
                }


                $(this).mouseover(function () {
                   
                    //$(rows[idx]).addClass('mouseovercolor').attr('style', 'cursor:pointer;cursor: hand;'); class로 주려면
                    $(rows[idx]).attr('style', 'cursor:pointer;cursor: hand;background-color:#f8f8f8;');

                });
                $(this).mouseout(function () {
                    $(rows[idx]).css('background-color', '').attr('style', '');
                });
            }


        });
        }
}

function fn_Delete() {
    var checked = $("table#rptbl tr input:checkbox:checked");
    $("#txtselectbox").val("");
    if (checked && checked.length > 0) {
            checked.each(function (index, fieldname) {
                if (fieldname.id == "") {
                    $("#txtselectbox").val($("#txtselectbox").val() + $(this).val() + ",");
                }
            });
    } else {
        alert('선택된게 없잖어!!!!');
        return false;
    }
}

'jquery' 카테고리의 다른 글

jQuery 속성(Attrbute)으로 셀렉터 하기...  (1) 2010.10.28
ImageNavi  (3) 2010.09.10
dynamic row  (1) 2010.09.09
select option의 첫번째 및 선택된 값 가져오기  (2) 2010.09.09
jquery 접근방식  (1) 2010.09.09
Posted by 정광원
,

Insert하는 프로시져 마지막에
Select @@Identity를
넣어준다.

'ms-sql' 카테고리의 다른 글

SQL 서버의 잠금에 대한 고찰  (1) 2010.09.10
CTE 방식으로 게시판 List Data가져오기  (3) 2010.09.10
CTE 정렬방법  (0) 2010.09.10
ms-sql 2008 설치  (1) 2010.09.09
value값 구분자 넣어서 자르기  (3) 2010.09.09
Posted by 정광원
,