Create Backup table Instantly :
The Following query automatically creates a Table with name "Table_Backup" and Insert all the rows of "Table_Old" into "Table_Backup"
Example :
SELECT * INTO Table_Backup FROM Table_Old
SELECT * INTO Table_Backup FROM Table_Old
link rel="stylesheet" type="text/css" href="style.css"
body { background-color: #FFFFF0; font-family: Arial, Verdana, sans-serif; font-size: 18px; color: #00008B; } a { font-family: Arial, Verdana, sans-serif; font-size: 18px; color: Blue; text-decoration: underline; } a:hover { font-family: Arial, Verdana, sans-serif; font-size: 18px; color: Red; background-color: Green; } h1 { font-family: Arial, Verdana, sans-serif; font-size: 32px; color: blue; } table { font-family: Arial, Verdana, sans-serif; font-size: 18px; color: #00008B; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; }
link rel="stylesheet" type="text/css" href="test.css"
/* Declaring variables */ DECLARE @Var1 AS int, @Var2 AS int /* The same can be done using SET, but two SET statements are needed */ SET @Var1 = 1 SET @Var2 = 2 /* Initializing two variables at once */ SELECT @Var1 = 1, @Var2 = 2
SET @Var1 = 1, @Var2 = 2 Msg 102, Level 15, State 1, Line 10 Incorrect syntax near ','.
/* Returns NULL */ DECLARE @Title varchar(80) --SET @Title = 'Not Found' SET @Title = ( SELECT error FROM SysMessages WHERE Description = 'Invalid Description' ) SELECT @Title GO /* Returns the string literal 'Not Found' */ DECLARE @Title varchar(80) SET @Title = 'Not Found' SELECT @Title = error FROM SysMessages WHERE Description = 'Invalid Description' SELECT @Title GO
/* Consider the following table with two rows */ SET NOCOUNT ON CREATE TABLE #Table (i int, j varchar(10)) INSERT INTO #Table (i, j) VALUES (1, 'Sunday') INSERT INTO #Table (i, j) VALUES (1, 'Monday') GO /* Following SELECT will return two rows, but the variable gets its value from one of those rows, without an error. you will never know that two rows existed for the condition, WHERE i = 1 */ DECLARE @j varchar(10) SELECT @j = j FROM #Table WHERE i = 1 SELECT @j GO /* If you rewrite the same query, but use SET instead, for variable initialization, you will see the following error */ DECLARE @j varchar(10) SET @j = (SELECT j FROM #Table WHERE i = 1) SELECT @j Msg 512, Level 16, State 1, Line 4 Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
DECLARE @j varchar(10) SELECT @j = (SELECT j FROM #Table WHERE i = 1) SELECT @j
SELECT @Var1 = @Var1 + 1, @Var2 = @Var2 - 1, @CNT = @CNT + 1