Please see the code below:

```
create table #Person (id int)
declare @ID int
SET @ID=9
SELECT @ID=ID FROM #Person WHERE ID=1
print @ID

```

I would expect nothing to be printed to the screen. Why is 9 printed to the screen?

@ID was originally initialised with '9', but then it should of changed to nothing?

**Update**

I have a .NET background. Please see the code below:

```
Public Shared Sub Test()
        Dim objCon As New SqlConnection(ConfigurationManager.ConnectionStrings("Connection").ConnectionString)
        Dim objCmd As New SqlCommand
        Dim testInt As Integer = 9

        Using objCon
            objCon.Open()
            If objCon.State = ConnectionState.Open Then
                objCmd.Connection = objCon
                objCmd.CommandText = "SELECT ID FROM Person where ID=1"
                testInt = CInt(objCmd.ExecuteScalar)
            End If
        End Using
    End Sub

```

testInt is initialised with 0 because nothing is returned by the command object (CInt(objCmd.ExecuteScalar)). Why is TSQL not consistent with .NET?

I realise there is probably a straightforward reason for this. However, I have never discovered this reason.