Client Statistics table (Microsoft SQL Server Management Studio)

Is there any way to clear the Client Statistics table in Microsoft SQL Server Management Studio (2008 R2) besides create a new query? Answer Go to the “Query” menu then choose “Reset Client Statistics”. You can customise the toolbar to add this function if you require it frequently. AttributionSource : Link , Question Author : … Read more

Multiple SQL statements in one roundtrip using Dapper.NET

There is a nice feature in ADO.NET that allows you to send multiple SQL statements to database in one roundtrip and receive results for all statements: var command = new SqlCommand(“SELECT count(*) FROM TableA; SELECT count(*) FROM TableB;”, connection); using(var reader = command.ExecuteReader()) { reader.Read(); resultA = reader.GetInt32(0); reader.NextResult(); reader.Read(); resultB = reader.GetInt32(0); } Is … Read more

Does Sql JOIN order affect performance?

I was just tidying up some sql when I came across this query: SELECT jm.IMEI , jm.MaxSpeedKM , jm.MaxAccel , jm.MaxDeccel , jm.JourneyMaxLeft , jm.JourneyMaxRight , jm.DistanceKM , jm.IdleTimeSeconds , jm.WebUserJourneyId , jm.lifetime_odo_metres , jm.[Descriptor] FROM dbo.Reporting_WebUsers AS wu WITH (NOLOCK) INNER JOIN dbo.Reporting_JourneyMaster90 AS jm WITH (NOLOCK) ON wu.WebUsersId = jm.WebUsersId INNER JOIN dbo.Reporting_Journeys … Read more

How to execute a stored procedure inside a select query

SELECT col1, col2, col3, EXEC GetAIntFromStoredProc(T.col1) AS col4 FROM Tbl AS T WHERE (col2 = @parm) How to write this SQL query in SQL Server 2008? Answer Thanks @twoleggedhorse. Here is the solution. First we created a function CREATE FUNCTION GetAIntFromStoredProc(@parm Nvarchar(50)) RETURNS INTEGER AS BEGIN DECLARE @id INTEGER set @id= (select TOP(1) id From … Read more