sys.columns
catalogue view Returns a row for each column of
an object that has columns, such as views or tables. The following is a list of
object types that have columns:
1. Table-valued assembly
functions (FT)
2. Inline table-valued
SQL functions (IF)
3. Internal tables (IT)
4. System tables (S)
5. Table-valued SQL
functions (TF)
6. User tables (U)
7. Views (V)
Example:
IF EXISTS(SELECT * FROM sys.columns
WHERE Name = N'IsACtive' and Object_ID = Object_ID(N'Products'))
BEGIN
-- Column Exists
PRINT 'Column IsACtive Exists'
End
Output:
Column IsACtive
Exists
Return Date part from DateTime:
You can
select only date or month from dateTime in SQL server
Example:
--in SQL Server 2008 or after
SELECT TOP 3 [ProductName], CONVERT(DATE,CreatedDate) as AddedDate FROM Products
--Before SQL Server 2008
SELECT TOP 3 [ProductName], convert(varchar(10), CreatedDate,120) as AddedDate FROM Products
Output:

Update from select using sql
server:
You can update records from another table, explained in below
example
Example without using join:
Update Products
SET isActive=1,
Products.[Description]=A.[Description]
FROM ActiveProducts A
Where Products.ProductCode=A.ProductCode
update using inner join :
Update P
SET P.isActive=1,
P.[Description]=A.[Description]
FROM
Products P
INNER JOIN ActiveProducts A
ON P.ProductCode=A.ProductCode