Sql server has a date function called DATENAME to get the name of the day or day of week
Oracle day name or day of week function
Mysql has a similar function called dayname() which is equivalent to datename in Microsoft SQL server
Different RDBMS provides system views with information about all the columns and their definitions in the database tables
SQLServer : SYS.COLUMNS (Microsoft)
INFORMATION_SCHEMA.COLUMNS (ANSI SQL)
Oracle : ALL_TAB_COLUMNS (ANSI SQL)
My Sql : INFORMATION_SCHEMA.COLUMNS (ANSI SQL)
Microsoft SQL server’s INFORMATION_SCHEMA.COLUMNS is equivalent to ALL_TAB_COLUMNS in oracle and INFORMATION_SCHEMA.COLUMNS in Mysql
ALL_TAB_COLUMNS in oracle is equivalent to Microsoft SQL server’s INFORMATION_SCHEMA.COLUMNS and INFORMATION_SCHEMA.COLUMNS in Mysql
INFORMATION_SCHEMA.COLUMNS in Mysql is equivalent to ALL_TAB_COLUMNS in oracle Microsoft SQL server’s INFORMATION_SCHEMA.COLUMNS and
SQL Server
select * from INFORMATION_SCHEMA.COLUMNS
Oracle
select * from ALL_TAB_COLUMNS
My SQL
select * from INFORMATION_SCHEMA.COLUMNS
We all know when reporiting any financial or sales information adding sub totals and grand totals to report makes it more effective but most offten develop0rs dont realize TSQL provides a effective way in doing this is using rollup and cube operators in group by clause.
So for this demo I am using Adventure works 2008 OLTP sample database
Three tables
here is a simple querying joining three tables and grouping by product category and subcategory
select
pc.ProductCategoryID,
s.ProductSubcategoryID,
AVG(ListPrice)as Avglistprice,
MAX (ListPrice)as MAxlistprice,
MAX(StandardCost)as Maxstandardcost
from Production.Product p
inner join Production.ProductSubcategory s
on p.ProductSubcategoryID = s.ProductSubcategoryID
inner join Production.ProductCategory pc
on pc.ProductCategoryID = s.ProductCategoryID
group by pc.ProductCategoryID,s.ProductSubcategoryID
SAMPLE RESULT
You can see we are missing some things in the above result i.e subtotals and grand totals
change group by cluase to include rollup operator like this
group by ROLLUP(pc.ProductCategoryID,s.ProductSubcategoryID)
trying running it with out errors
Result looks like this
CUBE is used as same way but it gives us a little different result , CUBE summarizes all the combinations of columns in group by clause and it also gives us grandtotal which does not make sense for above example because each sub category exists once in each category.
;WITH Dates AS
(
SELECT CAST(’2012-01-01′ AS DATE) [DateValue]
UNION ALL
SELECT DATEADD(D, 1, [DateValue]) FROM Dates
WHERE [DateValue] < ’2012-12-31′
)
SELECT * FROM Dates
OPTION (MAXRECURSION 367)
Statistics play an important role for the query optmizer to draw a optimizd execution plan , statistics are created against on indexed columns and and non indexed
column as default behaviour of sql server, but the point is how does sql server manage to update statistics when underlying data is updated are new data is inserted
lets see simple example when does sql server updates the statistics for indexed columns
SQL Server also updates the statistics
As a developer I was always curious to find when does sql server decides to for go Index seek or Index scan for a given table
DBCC SHOW_STATISTICS
Common Language Runtime (CLR) integration is a powerful feature ofSQL Server. CLR integration was introduced in SQL Server 2005, and it has beenextended in SQL Server 2008. Prior to SQL Server 2005, it was necessary to create extended stored procedures (XP) using C++ to take advantage of functionality beyond that provided by SQL Server natively. Today, CLR integration provides you with the flexibility to define stored procedures, functions, triggers,
data types, and other database objects using either Transact-SQL or any .NET Framework language.The advantage of this approach is that you can choose the language more suited to the task at hand
sp_configure ‘show advanced options’, 1;
GO
RECONFIGURE
GO
sp_configure ‘clr enabled’,1;
go
RECONFIGURE
go
Configuration option ‘show advanced options’ changed from 1 to 1. Run the RECONFIGURE statement to install.
Msg 5808, Level 16, State 1, Line 1
Ad hoc update to system catalogs is not supported.
to quick fix the above error use RECONFIGURE WITH OVERRIDE
Now, the reason why we are having that error is there is a setting called ‘allow updates’ which is a deprecated feature of SQL server 2000 , basically this allows the user to update the system tables directly in sql server although this feature is no longer available from SQL Server 2005 , but when this option is turned on or changed in SQL Sever 2005 or 2008 or R2, you will get an error message saying “Ad hoc update to system catalogs is not supported.” all though this feature is not supported then
why we are still receiving error ?, well when that option is changed, any “RECONFIGURE” is considered a side effect to the running server values but in this case if you use “WITH OVERRIDE” it worked as it overrides any warinings when we reconfigure
so do not use this feature
In case of UDF it is more important to know their limitations rather than their Benefits, the difference between UDF’s and Stored procedures is very less so you have to know the limitations which will help you to decide how to write your code
Now lets dissect this
For more details
Please use the below video
Returns the partition number into which a set of partitioning column values would be mapped for any specified partition function.
Syntax
[ database_name. ] $PARTITION.partition_function_name(expression)
It returns a Partition number of column value when mapped to a partition function
this will be useful if you want find the rows in a particular partition
so lets explain this with a simple example
create partition function
now lets create a partitioned table
insert some sample data
now lets see some examples on $partition function
Hi
in this demo we will learn what are Import Column and Export Column Transformations in SSIS
Import Column :
MSDN says:
The Import Column transformation reads data from files and adds the data to columns in a data flow. Using this transformation, a package can add text and images stored in separate files to a data flow
The data type of the output column must be DT_TEXT, DT_NTEXT, or DT_IMAGE.
So Import Column transformation reads a file from the file system any file (.jpeg,.doc,.pdf….) converts to into text stream and adds to the data flow a column ,
Export Column Transformation:

Export column does in exactly reverse to the Import column transformation
he Export Column transformation reads data in a data flow and inserts the data into a file. For example, if the data flow contains product information, such as a picture of each product, you could use the Export Column transformation to save the images to files.
You can configure the Export Column transformation in the following ways:
USE [SQLJUNKIESHARE]
GO
/****** Object: Table [dbo].[file] Script Date: 1/25/2012 7:04:55 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[file](
[id] [int] IDENTITY(1,1) NOT NULL,
[location] [varchar](100) NOT NULL,
[textfile] [varchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
So first we will use a FOR EACH LOOP CONTAINER with FILE ENUMERATOR to loop all the files in the source and insert the file locations in the DBO.FILE table
so lets execute package so far see the results
result of the import column
Now lets export text file column to a file location using export column transformation
drag and drop a data flow task and add a oledb source same as import column with table as file
so now we configured the export column transformation lets run
before running the destination look like this