Sunday, 3 January 2021

SQL SERVER Interview Questions And Answers | Babulal

1).  Remove Duplicate Records from a table?

Answer:

Select distinct * into #tmpEmp From Emp

Delete from Emp

Insert into Emp

Select * from #tmpEmp

Drop table #tmpEmp

Select * from Emp

2). What is the difference between "Stored Procedure" and "Function"?

Answer:

1. A stored procedure can have both input and output parameters, but a function can only have input parameters.

2.  We can use DML (INSERT/UPDATE/DELETE) statements inside a stored procedure. But  we can't use DML statements inside a function.

3. We can't utilize a stored procedure in a Select statement. But we can use a function in a Select statement.

4. We can use a Try-Catch Block in a stored procedure but inside a function we can't use a Try-Catch block.

5. Stored Procedures cannot be used in the SQL statements anywhere in the where/having/select section. But we can use a function anywhere.

6. A stored procedure can't be called from a function but we can call a function from a stored procedure.

7. We can use transaction management in a procedure but we can't in a function.

8. We can't join a stored procedure but we can join functions.


MVC Interview Questions And Answers| Babulal

Dot Net Interview Questions And Answers | Babulal

Sunday, 17 July 2016

sql helper class in c#

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

namespace Common
{
    public static class SQLFunctions
    {
        public static string PrepareSQLString(string sqlQuery)
        {
            sqlQuery = sqlQuery.Replace("'", "''");

            return sqlQuery;
        }

        public static string PrepareDateString(DateTime date)
        {
            string output = "";

            output = date.Day + "-" + CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(date.Month) + "-" + date.Year + " " + date.Hour + ":" + date.Minute + ":" + date.Second + ":" + date.Millisecond;

            return output;
        }
        public static int PrepareSQLString1(int dd)
        {
            int kkdd = 0;
            kkdd = Convert.ToInt32(dd.ToString());
            return kkdd;

        }
        public static decimal PrepareSQLString15(decimal dd)
        {
            decimal kkdd = 0.00m;
            kkdd = Convert.ToInt32(dd.ToString());
            return kkdd;

        }
    }

   
}

Saturday, 17 January 2015

This query used for find Lync user to PSTN user details



SELECT sd.SessionIdTime, sd.SessionIdSeq, sd.InviteTime, sd.FromUri, sd.ToUri, sd.FromUriType, sd.ToUriType, sd.FromTenant, sd.ToTenant, sd.FromEndpointId,
sd.ToEndpointId, sd.EndTime, sd.FromMessageCount, sd.ToMessageCount, sd.FromClientVersion, sd.FromClientType, sd.FromClientCategory, sd.ToClientVersion,
sd.ToClientType, sd.ToClientCategory, sd.TargetUri, sd.TargetUriType, sd.TargetTenant, sd.OnBehalfOfUri, sd.OnBehalfOfUriType, sd.OnBehalfOfTenant,
sd.ReferredByUri, sd.ReferredByUriType, sd.ReferredByTenant, sd.DialogId, sd.CorrelationId, sd.ReplacesDialogIdTime, sd.ReplacesDialogIdSeq,
sd.ReplacesDialogId, sd.ResponseTime, sd.ResponseCode, sd.DiagnosticId, sd.ContentType, sd.FrontEnd, sd.Pool, sd.FromEdgeServer, sd.ToEdgeServer,
sd.IsFromInternal, sd.IsToInternal, sd.CallPriority, sd.MediaTypes, sd.FromUserFlag, sd.ToUserFlag, sd.CallFlag, sd.Location, p1.PhoneUri AS FromPhone,
p2.PhoneUri AS ToPhone, u.UserUri AS DisconnectedByUri, u.UserUriType AS DisconnectedByUriType, u.TenantKey AS DisconnectedByTenant,
p3.PhoneUri AS DisconnectedByPhone, ms1.MediationServer AS FromMediationServer, ms2.MediationServer AS ToMediationServer, gw1.Gateway AS FromGateway,
gw2.Gateway AS ToGateway
FROM dbo.VoipDetails AS vd LEFT OUTER JOIN
dbo.SessionDetailsView AS sd ON vd.SessionIdTime = sd.SessionIdTime AND vd.SessionIdSeq = sd.SessionIdSeq LEFT OUTER JOIN
dbo.UsersView AS u ON vd.DisconnectedByURIId = u.UserId LEFT OUTER JOIN
dbo.Phones AS p1 ON vd.FromNumberId = p1.PhoneId LEFT OUTER JOIN
dbo.Phones AS p2 ON vd.ConnectedNumberId = p2.PhoneId LEFT OUTER JOIN
dbo.Phones AS p3 ON vd.DisconnectedByPhoneId = p3.PhoneId LEFT OUTER JOIN
dbo.MediationServers AS ms1 ON vd.FromMediationServerId = ms1.MediationServerId LEFT OUTER JOIN
dbo.MediationServers AS ms2 ON vd.ToMediationServerId = ms2.MediationServerId LEFT OUTER JOIN
dbo.Gateways AS gw1 ON vd.FromGatewayId = gw1.GatewayId LEFT OUTER JOIN
dbo.Gateways AS gw2 ON vd.ToGatewayId = gw2.GatewayId
where sd.MediaTypes=16 and ( ms1.MediationServer is null and ms2.MediationServer ='host-17.app.devcn.com' )
and (sd.FromUriType='UserUri' and sd.ToUriType='PhoneUri')

Monday, 13 October 2014

DevCentrics - Lync Solution Provider