Search This Blog

Wednesday, October 17, 2018

How can get MSSQL Table, StorePocedures, View & Triggers by query



 Query for Table:


 SELECT COUNT(*) AS TABLECOUNT FROM sys.Tables

Query for Store Procedures:


 select count(*) as ProceduresCount from sys.procedures

Query for Triggers:


 SELECT count(*) AS TriggersCount FROM sys.triggers

Query for Views:


 SELECT count(*) AS ViewsCount FROM sys.views




SELECT 'Count' = COUNT(*), 'Type' = CASE type
                WHEN 'C' THEN 'CHECK constraints'
                WHEN 'D' THEN 'Default or DEFAULT constraints'
                WHEN 'F' THEN 'FOREIGN KEY constraints'
                WHEN 'FN' THEN 'Scalar functions'
                WHEN 'IF' THEN 'Inlined table-functions'
                WHEN 'K' THEN 'PRIMARY KEY or UNIQUE constraints'
                WHEN 'L' THEN 'Logs'
                WHEN 'P' THEN 'Stored procedures'
                WHEN 'R' THEN 'Rules'
                WHEN 'RF' THEN 'Replication filter stored procedures'
                WHEN 'S' THEN 'System tables'
                WHEN 'TF' THEN 'Table functions'
                WHEN 'TR' THEN 'Triggers'
                WHEN 'U' THEN 'User tables'
                WHEN 'V' THEN 'Views'
                WHEN 'X' THEN 'Extended stored procedures'
    END

    FROM sys.objects
    GROUP BY type
    ORDER BY type



Count
Type
5
NULL
47
NULL
3
NULL
62
Default or DEFAULT constraints
33
FOREIGN KEY constraints
27
Stored procedures
45
System tables
1
Table functions
54
User tables







Thursday, September 20, 2018

G-Suits Issue - SmtpException: Unable to read data from the transport connection: net_io_connectionclosed



Common error in G-suits account for sending  SMTP mail .


When getting error :


G-Suits Issue - SmtpException: Unable to read data from the transport connection: net_io_connectionclosed


Solution : 


The most simple way to test is to try using port 587 and not 465. While some SMTP servers support TLS on 465 (and sometimes even 25), only port 587 is required to support TLS. 



 SmtpClient sm = new SmtpClient();
            sm.EnableSsl = true;
            sm.Host = "smtp.gmail.com";
            sm.Port = 587;//465;
            sm.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
            sm.UseDefaultCredentials = false;
            sm.Credentials = new NetworkCredential("email", "password");
            sm.ServicePoint.MaxIdleTime = 1;
            sm.Send(ms);
            ms.Dispose();