15 Jan by dbtut

Must declare the scalar variable “@variable”

  If there is a variable in the script we run and we have not declared this variable, we will get this error. For example, with the help of the following script, let’s create a table named “databaseandlogins” in the “TestDB” database. [crayon-5c3e6e1f27681456331652/] Then try to add data to this table as follows. [crayon-5c3e6e1f27688173232324/] When […]
15 Jan by dbtut Tags: , , , ,

How To Find and Change Owner of All Databases in an Instance in SQL SERVER

  Sometimes, we can receive the below error. SSPI handshake failed with error code 0x8009030c, state 14 while establishing a connection with integrated security; the connection has been closed. Reason: AcceptSecurityContext failed. The Windows error code indicates the cause of failure. The logon attempt failed   [CLIENT: 1.1.1.1] The reason for this error may be that […]
14 Jan by dbtut Tags: ,

UNION and UNION ALL Operators in SQL Server(TSQL)

  With UNION and UNION ALL Opertors, we can merge multiple sql statement’s result in a single result set. When we merge two SQL statements with the UNION operator, duplicate records are listed once in the result set. When we merge two SQL statements with the UNION ALL operator, all results are listed. If there […]
13 Jan by dbtut Tags: , , , , , , , , , , , , ,

SQL Server Conditions and Loops(TSQL)

  In this article, we will examine the loops and conditions we use in TSQL. Conditions in TSQL: IF Statement in SQL Server: You can use it as follows. [crayon-5c3e6e1f280db927817914/] IF…ELSE Statement in SQL Server: You can use it as follows. We’re running the same IF … ELSE Statement twice by changing the parameter value. […]
13 Jan by dbtut

SQL Server Data Types(TSQL)

It is a very critical step to correctly determine SQL Server Data Types when designing tables to prevent unnecessary growth of the database. The space that data types allocate on the disk is different. For example, suppose you have a column in your table that will contain numbers. If the value of this column will […]
13 Jan by dbtut

Declare Variables in SQL Server(TSQL)

  In this article I will describe how to declare variables in TSQL. We can declare variables in a few different ways. • Declare a single variable • Declare multiple variables at once • Set values when declaring variables • Set values when declaring multiple variables at once Declaring g a single variable: [crayon-5c3e6e1f2834c605291822/] We […]
11 Jan by dbtut Tags: , , , , , , , , ,

ALTER TABLE Statement in SQL Server(TSQL)

We can perform the following operations with ALTER TABLE Statement. Add a column to a table Delete a column from a table Change the data type of a column Increase or decrease the size of a column Switch Partition Enable or disable Constraints or triggers In this article I will describe the above items through […]
9 Jan by dbtut Tags: , , , , , , , ,

GRANT, REVOKE and DENY Commands in SQL Server(TSQL)

You can use GRANT, REVOKE, and DENY commands on many database objects in SQL Server. With the GRANT command, you can authorize a user. With the REVOKE command, you can revoke a given authorization. With the DENY command, you can deny an authorization. In this article we will examine where we can use these commands. […]
8 Jan by dbtut Tags: ,

SubQueries in SQL Server(TSQL)

  In SQL Server, you can write query in a query. You can write the subqueries in the SELECT section, FROM section, and the WHERE section of the query. The Main query is also known as OUTER QUERY or OUTER SELECT, and subquery is known as INNER QUERY or INNER SELECT In the following example, […]
7 Jan by dbtut

IN Operator in SQL Server(TSQL)

  When filtering through the Where Clause during data reading from the database, the IN operator can check whether the column is within certain values. Let’s make an example for a better understanding of the subject. First, we create a table as below and add a few records to the table. [crayon-5c3e6e1f28e1c939590781/] Find people whose […]