Tags » T-SQL

SQL SERVER - Generate Different Random Number for Each Group Using RAND() Function

You know that RAND() function in SQL Server generates a random float value 0 through 1 (excluding 0 and 1).

Let us create the following dataset… 222 more words

SQL Authority

How to post a T-SQL question on a public forum

If you want to have faster turnaround on your forum questions, you will need to provide enough information to the forum users in order to answer your question. 647 more words

SQL Server

How to calculate the number of working minutes...FAST :)

This is always a performance thing, ETL-wise, but also in stored procedures.
I’ve published an example on how to calculate the number of working days (rounded) via a scalar-valued function: 118 more words

SQL

SQL Server - Error While Enabling CDC on a Table - The specified '@server' is invalid (valid values are returned by sp_helpserver)

Every environment is different and it is no doubt some of these environment changes can give you results that are not expected. Recently one of my blog reader followed below blogs: 477 more words

SQL Authority

SQL SERVER - Different Methods to Know Parameters of Stored Procedure

Suppose you have a stored procedure with some input parameters. There are two methods to know the list of parameters defined in a stored procedure. 145 more words

SQL Authority

What permission should we grant to view an execution plan?

Apart form db_datareader  we have to grant  SHOWPLAN permission at the database level.

USE DatabaseName
Go

Grant SHOWPLAN to

Note: sysadmin, dbcreator or db_owner ‘s can see the execution plan with out showplan permission.

SQL Server

Replace cursors with set based operations

打字猴平常寫SQL的時候幾乎沒在用Cursor,因為會有performance上的問題。

其實寫SQL主要是用Set based approach而不是像一般programming language一樣用Procedural approach;但是Cursor和T-SQL的User-Defined Function(UDF)就是用Procedural approach。 225 more words