Tuesday, March 29, 2016

Shrink Log Space in SQL

DBCC LOGINFO(DB_NAME)
BACKUP LOG [DB_NAME] TO DISK = 'E:\Program Files\Microsoft SQL Server\MSSQL\Backup\DB_NAME.bak'
DBCC SHRINKFILE(NEWDATACOLLECT_Log)--right click db goto properties then files menu there you can get log name
DBCC LOGINFO(DB_NAME)




Monday, March 28, 2016

SQL : Delete multiple tables in db having record more than 10,000

create proc myproc
as 
begin
DECLARE @name VARCHAR(50),@fileName VARCHAR(256),@deleteInt int
CREATE TABLE ##Temp
    (
        Count   integer NOT NULL,
        Name        nvarchar(50) 
    );
DECLARE db_cursor CURSOR FOR 
SELECT top 1000
 t.NAME AS TableName--,
 --i.name AS indexName,
 --SUM(p.rows) AS RowCounts,
 --SUM(a.total_pages) AS TotalPages, 
 --SUM(a.used_pages) AS UsedPages, 
 --SUM(a.data_pages) AS DataPages,
 --(SUM(a.total_pages) * 8) / 1024 AS TotalSpaceMB, 
 --(SUM(a.used_pages) * 8) / 1024 AS UsedSpaceMB, 
 --(SUM(a.data_pages) * 8) / 1024 AS DataSpaceMB
FROM 
 sys.tables t
INNER JOIN  
 sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN 
 sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN 
 sys.allocation_units a ON p.partition_id = a.container_id
WHERE 
 t.NAME NOT LIKE 'dt%' AND
 i.OBJECT_ID > 255 AND  
 i.index_id <= 1
GROUP BY 
 t.NAME, i.object_id, i.index_id, i.name 
--ORDER BY 
---- OBJECT_NAME(i.object_id) 
--8 desc 
--SELECT name ,size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS int)/128.0 AS AvailableSpaceInMB FROM sys.database_files order by 2; select * from sys.database_files
OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @name 
WHILE @@FETCH_STATUS = 0   
BEGIN  
       SET @fileName = 'select count(*),'+ '''' + @name + '''' + ' FROM dba.' + @name  
       INSERT  ##Temp (Count,Name)    
  EXEC (@fileName) 
       FETCH NEXT FROM db_cursor INTO @name   
END  
CLOSE db_cursor   
DEALLOCATE db_cursor  

DELETE FROM ##Temp where COUNT <= 10000
set @deleteInt = 0
DECLARE db_cursor1 CURSOR FOR select name from ##Temp
OPEN db_cursor1   
FETCH NEXT FROM db_cursor1 INTO @name
WHILE @@FETCH_STATUS = 0
BEGIN 
Set @deleteInt = (select top 1 COUNT from ##Temp where Name = @name)  
SET @deleteInt = @deleteInt - 10000 
    SET @fileName = 'DELETE top(' + CAST(@deleteInt AS VARCHAR(10)) +  ')' + 'FROM dba.' + @name 
print @fileName
exec (@filename)
FETCH NEXT FROM db_cursor1 INTO @name  
END   

CLOSE db_cursor1  
DEALLOCATE db_cursor1
end
go

exec myproc



Thursday, September 12, 2013

turtle-entertainment.de here is your Heart of the Swarm Beta Key! EJR6GK-BF9M-TBECEC-TR7X-RT9EB7 Enjoy!

Thursday, July 25, 2013

Value Response Header Get Set Cookie In C#



var client = new HttpClient();
    client.MaxResponseContentBufferSize = Int32.MaxValue;
    HttpResponseMessage response = await client.GetAsync(new Uri("http://www.google.com"));
string j = (response.Headers.ToString());
    IList<string> valu = j.Split(' ').Reverse().ToList<string>();
    for (int i = 0; i < j.Length; i++)
    {      
        if (valu[i].StartsWith("JSESSIONID"))//if Set-Cookie
        {
            var s = valu[i];
            char[] delimiters = new[] { ',', ';', ' ' };  // List of your delimiters
            var splitte = s.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
            s = splitte[0].Replace("JSESSIONID=", "");        
        }
    }

Tuesday, July 23, 2013

Add dll to gac in windows 8 using Command Prompt(normal in administrative mode)


Set Focus State Code

TextBox1.Focus(Windows.UI.Xaml.FocusState.Pointer);

Wednesday, July 17, 2013

ADDING STRONG NAME TO EXISTING DLL IN VS 2010

code :

Setting environment for using Microsoft Visual Studio 2010 x86 tools

Step 1 : Run visual studio command prompt and go to directory where your DLL located.

  For Example my DLL located in D:/Test.dll

Step 2 : Now create il file using below command.

  D:/> ildasm /all /out=Test.il Test.dll 
  (this command generate code library)

Step 3 : Generate new Key for sign your project.

  D:/> sn -k mykey.snk

Step 4 : Now sign your library using ilasm command.

  D:/> ilasm /dll /key=mykey.snk Test.il

so after this step your assembly contains strong name and signed. 


example done successfully :


C:\>ildasm /all /out=eCOS_ConnSharepoint.il eCOS_ConnSharepoint.dll

C:\>sn -k mykey.snk

Microsoft (R) .NET Framework Strong Name Utility  Version 4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Key pair written to mykey.snk

C:\>ilasm /dll /key=mykey.snk eCOS_ConnSharepoint.il

Microsoft (R) .NET Framework IL Assembler.  Version 4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.
Assembling 'eCOS_ConnSharepoint.il'  to DLL --> 'eCOS_ConnSharepoint.dll'
Source file is ANSI

Assembled method eCOS_ConnSharepoint.eCOS_fileLoader::UploadFileToDocLib
Assembled method eCOS_ConnSharepoint.eCOS_fileLoader::.ctor
Creating PE file

Emitting classes:
Class 1:        eCOS_ConnSharepoint.eCOS_fileLoader

Emitting fields and methods:
Global
Class 1 Methods: 2;

Emitting events and properties:
Global
Class 1
Writing PE file
Signing file with strong name
Operation completed successfully

C:\>gacutil.exe /i c:\eCOS_ConnSharepoint.dll
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Assembly successfully added to the cache

Tuesday, July 16, 2013

Enter Click Login Button Press Event occur in Password box

code:

 private void pwd_KeyDown(object sender, KeyRoutedEventArgs e)
        {        
            if (e.Key == Windows.System.VirtualKey.Enter)
            {
                loginclick_Click(this, new RoutedEventArgs());
            }

        }