Assign Variables in a Query

DECLARE @ID1 INT,
	@ID2 VARCHAR(100),
	@ID3 INT,
	@ID4 VARCHAR(100);

SET @ID1 = 1;
SET @ID2 = 'One';

SELECT @ID3 = 1,
	@ID4 = 'One';

Datatypes

DECLARE @Num1 INT = 1;
DECLARE @Num2 INT = 2;

SELECT 1 / 2 AS [Result1], -- 0
	@Num1 / @Num2 AS [Result2], -- 0
	CAST(0.5 AS INT) [Result3] -- 0

SELECT 
	1 / 2 * 1. AS [Result4], -- 0
	1. * 1 / 2 AS [Result5], -- 0.500000
	1. * 1 / 2 * 1.0 AS [Result6] -- 0.5000000

Default Datatype of NULL value in a Query

SELECT NULL AS [TestNull]
INTO #TempTable;
EXEC tempdb..sp_columns #TempTable;

Dilemmas of SELECT *