Friday, January 31, 2014

how to know user define function created date

SELECT name, create_date, modify_date
FROM sys.objects
WHERE type = 'fn'
AND name = 'fn_Connection'




SELECT dbo.udf_GetNumDaysInMonth(GETDATE()) NumDaysInMonth

how to know store procedure created date

SELECT namecreate_datemodify_dateFROM sys.objectsWHERE type 'P'AND name 'lsp_PropGetCrntSugsn'





SELECT nameFROM sys.objectsWHERE type 'P'AND DATEDIFF(D,modify_dateGETDATE()) < 7----Change 7 to any other day value
Following script will provide name of all the stored procedure which were created in last 7 days, they may or may not be modified after that.

SELECT nameFROM sys.objectsWHERE type 'P'AND DATEDIFF(D,create_dateGETDATE()) < 7----Change 7 to any other day value.

How to know table created date

SELECT create_date FROM sys.tables WHERE name='tblUsrShrProp'




SELECT
        [name]
       ,create_date
       ,modify_date
FROM
        sys.tables




SELECT su.name,so.name,so.crdate,* FROM sysobjects so JOIN sysusers su ON so.uid = su.uid WHERE xtype='U' ORDER BY so.name


SELECT OBJECT_NAME(OBJECT_ID) AS DatabaseName, last_user_update,* FROM sys.dm_db_index_usage_stats WHERE database_id = DB_ID( 'developer') AND OBJECT_ID=OBJECT_ID('tblusrshrprop')

Wednesday, January 22, 2014

how to call web method in java script

<script>
 function DonwnlodFile(PLocMapFilePath) {

            $.ajax({
                type: "POST",
                url: '<%=ResolveUrl("~/Services/Property/Property.asmx/download") %>',
                data: "{}",
                contentType: "application/json; charset=utf-8",
                success: function (res) {
                    alert("Sdsdasad");
                    alert(res);
                    //  console.log("donwloaded");
                }
            });
        }

<script>





In services

    public void download()
    {
        string filename = "test.txt";
        string path = "C:\\Users\\JITENDRA\\Desktop\\test.txt";

        byte[] ls1 = DownloadFile(path);
        HttpResponse response = Context.Response;

        response.Clear();
        response.BufferOutput = true;
        response.ContentType = "application/octet-stream";
        response.ContentEncoding = Encoding.UTF8;
        response.AppendHeader("content-disposition", "attachment; filename=" + filename);

        response.BinaryWrite(ls1);

        response.Flush();
        response.Close();
    }

    [WebMethod()]
    public byte[] DownloadFile(string FName)
    {
        System.IO.FileStream fs1 = null;
        fs1 = System.IO.File.Open(FName, FileMode.Open, FileAccess.Read);
        byte[] b1 = new byte[fs1.Length];
        fs1.Read(b1, 0, (int)fs1.Length);
        fs1.Close();
        return b1;
    }