tag:blogger.com,1999:blog-13476025284293877592024-02-19T04:31:05.827-08:00BI Learning HubThis blog will provide real time solutions in SQL, SSRS, SSIS, DWH, Tableau, Analytics Solution, Agile - Scrum, Salesforce Einstein Analytics (Tableau CRM) and many more. Keep Learning!Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.comBlogger82125tag:blogger.com,1999:blog-1347602528429387759.post-72695239846821575042021-10-28T08:07:00.004-07:002021-10-28T08:07:41.298-07:00Tableau interview questions and answers for experienced professionals<p> </p><p class="MsoNormal" style="background: white; line-height: normal; text-align: center;"><b><span style="font-family: "Open Sans", sans-serif;"><u>Tableau Interview Questions and Answers for experienced professional</u><span style="font-size: 18pt;"><o:p></o:p></span></span></b></p><p class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3;"><b><span style="font-family: "Open Sans", sans-serif; font-size: 13.5pt;">1. What is TABLEAU?<o:p></o:p></span></b></p><p class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"><b><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">Tableau</span></b><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;"> is the powerful
and fastest visualizing tool that is used in the Business Intelligence(BI)
Industry. It simplifies the raw data into an understandable format. Analysis of
the data becomes faster with Tableau. The visualizations can be created in the
form of dashboards. The visualizations or diagrammatic representation of data
can easily be understood by the employees of the organizations who are at
different levels.<o:p></o:p></span></p><h3 style="background: white;"><span style="font-family: "Open Sans", sans-serif;">2. List out Tableau File Extensions.<o:p></o:p></span></h3><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">The below ones are few extensions in Tableau:<o:p></o:p></span></p><ol start="1" style="box-sizing: border-box;" type="1"><li class="MsoNormal" style="background: white; box-sizing: border-box; line-height: 200%;"><span style="font-family: "Open Sans",sans-serif; font-size: 11.5pt; line-height: 200%;">Tableau Workbook
(.twb)<o:p></o:p></span></li>
<li class="MsoNormal" style="background: white; box-sizing: border-box; line-height: 200%;"><span style="font-family: "Open Sans",sans-serif; font-size: 11.5pt; line-height: 200%;">Tableau Data extract
(.tde)<o:p></o:p></span></li>
<li class="MsoNormal" style="background: white; box-sizing: border-box; line-height: 200%;"><span style="font-family: "Open Sans",sans-serif; font-size: 11.5pt; line-height: 200%;">Tableau Datasource
(.tds)<o:p></o:p></span></li>
<li class="MsoNormal" style="background: white; box-sizing: border-box; line-height: 200%;"><span style="font-family: "Open Sans",sans-serif; font-size: 11.5pt; line-height: 200%;">Tableau Packaged
Datasource (.tdsx)<o:p></o:p></span></li>
<li class="MsoNormal" style="background: white; box-sizing: border-box; line-height: 200%;"><span style="font-family: "Open Sans",sans-serif; font-size: 11.5pt; line-height: 200%;">Tableau Bookmark
(.tbm)<o:p></o:p></span></li>
<li class="MsoNormal" style="background: white; box-sizing: border-box; line-height: 200%;"><span style="font-family: "Open Sans",sans-serif; font-size: 11.5pt; line-height: 200%;">Tableau Map Source
(.tms)<o:p></o:p></span></li>
<li class="MsoNormal" style="background: white; box-sizing: border-box; line-height: 200%;"><span style="font-family: "Open Sans",sans-serif; font-size: 11.5pt; line-height: 200%;">Tableau Packaged
Workbook (.twbx) – zip file containing .twb and external files.<o:p></o:p></span></li>
<li class="MsoNormal" style="background: white; box-sizing: border-box; line-height: 200%;"><span style="font-family: "Open Sans",sans-serif; font-size: 11.5pt; line-height: 200%;">Tableau Preferences
(.tps)<o:p></o:p></span></li>
</ol><h3 style="background: white;"><span style="font-family: "Open Sans", sans-serif;">Define different connection types in Tableau?<o:p></o:p></span></h3><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">There are 2 connection types available in Tableau.<o:p></o:p></span></p><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><strong style="box-sizing: border-box;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">Extract</span></strong><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">:
Extract is a snapshot of data that will be extracted from the data source and
put into the Tableau repository. This snapshot can be refreshed periodically
fully or incrementally. This can be scheduled in Tableau Server<o:p></o:p></span></p><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><strong style="box-sizing: border-box;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">Live</span></strong><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">: It
creates a direct connection to the data source and data will be fetched
directly from tables. So, data will be up to date and consistent. But, this
also affects access speed.<o:p></o:p></span></p><h3 style="background: white;"><span style="font-family: "Open Sans", sans-serif;">Define fact and dimensions?<o:p></o:p></span></h3><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">Facts are numeric measures of data. They are stored in fact
tables. Fact tables store that type of data that will be analyzed by dimension
tables. Fact tables have foreign keys associated with dimension tables.<o:p></o:p></span></p><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">Dimensions are descriptive attributes of data. Those will be
stored in the dimensions table. For example, customers’ information like name,
number, and email will be stored in the dimension table.<o:p></o:p></span></p><p class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3;"><b><span style="font-family: "Open Sans", sans-serif; font-size: 13.5pt;">What are the different Joins in Tableau?<o:p></o:p></span></b></p><p class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">Tableau
works the same as SQL. So, it supports all Joins possible in SQL<o:p></o:p></span></p><ul type="disc">
<li class="MsoNormal" style="background: white; line-height: 200%;"><span style="font-family: "Open Sans",sans-serif; font-size: 11.5pt; line-height: 200%; mso-fareast-font-family: "Times New Roman";">Left
Outer Join<o:p></o:p></span></li>
<li class="MsoNormal" style="background: white; line-height: 200%;"><span style="font-family: "Open Sans",sans-serif; font-size: 11.5pt; line-height: 200%; mso-fareast-font-family: "Times New Roman";">Right
Outer Join<o:p></o:p></span></li>
<li class="MsoNormal" style="background: white; line-height: 200%;"><span style="font-family: "Open Sans",sans-serif; font-size: 11.5pt; line-height: 200%; mso-fareast-font-family: "Times New Roman";">Full
Outer Join<o:p></o:p></span></li>
<li class="MsoNormal" style="background: white; line-height: 200%;"><span style="font-family: "Open Sans",sans-serif; font-size: 11.5pt; line-height: 200%; mso-fareast-font-family: "Times New Roman";">Inner
Join<o:p></o:p></span></li>
</ul><h3 style="background: white;"><span style="font-family: "Open Sans", sans-serif;">What is Tableau Reader?<o:p></o:p></span></h3><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><span style="box-sizing: border-box;"><strong style="box-sizing: border-box;"><span style="font-family: "Open Sans", sans-serif;">Tableau Reader</span></strong><span style="font-family: "Open Sans", sans-serif;"> is a free desktop
application, where you can read and interact with the Tableau packaged
workbooks. It can only open the files but cannot create new connections to the
workbook.</span></span><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;"><o:p></o:p></span></p><h3 style="background: white;"><span style="font-family: "Open Sans", sans-serif;">Define Page Shelf in Tableau?<o:p></o:p></span></h3><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">Page shelf breaks the views into a series of pages. It displays an
alternate view on each page. Due to this feature, you can analyze the effect of
each field on the rest of the data in the view.<o:p></o:p></span></p><h3 style="background: white;"><span style="font-family: "Open Sans", sans-serif;">What is published data and embedded data sources?<o:p></o:p></span></h3><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">The published data source contains connection information that is
independent of workbooks and can be used by multiple workbooks.<o:p></o:p></span></p><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">The embedded data source contains connection information but it is
associated with the workbooks.<o:p></o:p></span></p><h3 style="background: white;"><span style="font-family: "Open Sans", sans-serif;">Differentiate parameters and filters in Tableau<o:p></o:p></span></h3><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><strong style="box-sizing: border-box;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">Filters</span></strong><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;"> are
the simpler and straightforward feature in Tableau. It applies to dimensions or
measures directly. For example, to only show Gujarat or Karnataka in a State
dimension, we can apply the filter on that. In Tableau, there are multiple UI
options available for filters like radio buttons, drop-down lists, checkboxes,
sliders, and more. Filters on sheets are also available in Tableau.<o:p></o:p></span></p><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><strong style="box-sizing: border-box;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">Parameters</span></strong><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;"> are
like variables. They are complex and more powerful. Like a variable, a
parameter can be used in calculations. So, that means, it only allows a single
value. Parameters have the same UI options except for checkboxes because
checkboxes don’t have a single value. For example, we can create a parameter
for interest rate and period, and then we can use these parameters to calculate
interest and principal payments.<o:p></o:p></span></p><h3 style="background: white;"><span style="font-family: "Open Sans", sans-serif; font-size: 12pt;">Different types of filters are available in Tableau?</span><span style="font-family: "Open Sans", sans-serif;"><o:p></o:p></span></h3><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">Filters are used to provide the correct information to viewers
after removing unnecessary data. There are various types of filters available
in Tableau.<o:p></o:p></span></p><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><strong style="box-sizing: border-box;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">Extract Filters</span></strong><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;"> –
Extract filters are used to apply filters on extracted data from the data
source. For this filter, data is extracted from the data source and placed into
the Tableau data repository.<o:p></o:p></span></p><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><strong style="box-sizing: border-box;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">Datasource Filters</span></strong><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;"> –
Datasource filters are the same as extract filters. They also work on the
extracted dataset. But, the only difference is it works with both live and
extract connections.<o:p></o:p></span></p><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><strong style="box-sizing: border-box;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">Context Filters</span></strong><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;"> –
Context Filters are applied on the data rows before any other filters. They are
limited to views, but they can be applied on selected sheets. They define
Aggregation and Disaggregation of data in Tableau<o:p></o:p></span></p><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><strong style="box-sizing: border-box;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">Dimension Filters</span></strong><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;"> –
Dimension filters are used to apply filters on dimensions in worksheets.
Dimension filters are applied through the top or bottom conditions, formula,
and wildcard match.<o:p></o:p></span></p><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><strong style="box-sizing: border-box;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">Measure Filters</span></strong><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;"> –
Measure filters are applied to the values present in the measures.<o:p></o:p></span></p><h3 style="background: white;"><span style="font-family: "Open Sans", sans-serif;">Differentiate between Tiled and Floating in dashboards?<o:p></o:p></span></h3><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">In a tiled layout, items don’t overlap. The layout will be
adjusted according to dashboard size. In the floating layout, items can be
placed on some other layers. Floating items can have fixed positions and sizes.<o:p></o:p></span></p><h3 style="background: white;"><span style="font-family: "Open Sans", sans-serif;">What is Data Modelling?<o:p></o:p></span></h3><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">Data modeling is the analysis of data objects that are used in a
business or other context and also used as identification of the relationships
among these data objects. It is the first step of doing object-oriented
programming.<o:p></o:p></span></p><h3 style="background: white;"><span style="font-family: "Open Sans", sans-serif;">Differentiate discrete and continuous data roles in Tableau<o:p></o:p></span></h3><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important; text-align: justify;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">Discrete data roles consist of values that are separate and
distinct. Discrete data roles can take individual values within a range. For
Example – cancer patients in the hospital, no. of threads in a sheet, state.
Discrete values are displayed as blue icons in the data window and blue pills
on shelves. Discrete fields can be sorted.<o:p></o:p></span></p><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important; text-align: justify;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">Continuous data roles consist of any value within the finite or
infinite intervals. For Example – age, unit price, order quantity. Continuous
values displayed as green icons in the data window and green pills on shelves.
Continuous fields cannot be sorted.<o:p></o:p></span></p><h3 style="background: white;"><span style="font-family: "Open Sans", sans-serif;">Extract or Live connection, which one is better?<o:p></o:p></span></h3><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">Extract connection is better than live connection because extract
connection can be used from anywhere, anytime without <a href="https://mindmajix.com/connect-data-generated-values-tableau" style="appearance: none !important; box-sizing: border-box;" target="_blank"><span style="text-decoration-line: none;">connecting to the database</span></a>.
We can construct our own visualizations on it irrespective of the database
connection.<o:p></o:p></span></p><p class="MsoNormal" style="background: white; line-height: 16.5pt; margin-bottom: 0in; vertical-align: baseline;"><b><span style="font-family: "Open Sans", sans-serif; font-size: 13.5pt;">What are Calculated
Fields?<o:p></o:p></span></b></p><p class="MsoNormal" style="background: white; line-height: 19.5pt; margin-bottom: 22.5pt; vertical-align: baseline;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">A Calculated Field is a
user-created field that can include operations on other fields that are present
in the data. A calculated field does not impact the original data but rather
creates a new field that contains the results of the operations conducted on
the data.<o:p></o:p></span></p><p class="MsoNormal" style="background: white; line-height: 16.5pt; margin-bottom: 0in; vertical-align: baseline;"><b><span style="font-family: "Open Sans", sans-serif; font-size: 13.5pt;">What is the difference
between a TWB and a TWBX file?<o:p></o:p></span></b></p><p class="MsoNormal" style="background: white; line-height: 19.5pt; margin-bottom: 22.5pt; vertical-align: baseline;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">A TBW file is the basic
Tableau file, which contains instructions regarding how Tableau interacts with
a particular source of data. However, the data source needs to be attached
separately and placed at an appropriate location for Tableau to interact with
it. A TWBX file is a Tableau package, which contains the entirety of the data
to be analyzed as well as the analysis.<o:p></o:p></span></p><p class="MsoNormal" style="background: white; line-height: 16.5pt; margin-bottom: 0in; vertical-align: baseline;"><b><span style="font-family: "Open Sans", sans-serif; font-size: 13.5pt;">What is a blended axis?<o:p></o:p></span></b></p><p class="MsoNormal" style="background: white; line-height: 19.5pt; margin-bottom: 22.5pt; vertical-align: baseline;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">Very often, in Tableau,
you may need to present multiple graphs in the same Cartesian plane. These
graphs may have to be derived from different measures. You can do so with a
blended y-axis. The caveat to incorporating a blended axis is that the unit and
scale of the two measures must be the same.<o:p></o:p></span></p><p class="MsoNormal" style="background: white; line-height: 16.5pt; margin-bottom: 0in; vertical-align: baseline;"><b><span style="font-family: "Open Sans", sans-serif; font-size: 13.5pt;">What are Groups in
Tableau?<o:p></o:p></span></b></p><p class="MsoNormal" style="background: white; line-height: 19.5pt; margin-bottom: 22.5pt; vertical-align: baseline;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">A Group in Tableau is a
collection of categories that can be used to create a single overarching
subcategory. An example can be considered from the Superstore data set, in
which several different product subcategories are present. You can create a
group of any number of these subcategories and create a single category for
analysis.<o:p></o:p></span></p><h3 style="background: white;"><span style="font-family: "Open Sans", sans-serif;">What is the difference between a Heat map and Treemap?<o:p></o:p></span></h3><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">TreeMap Heat MapIt represents the data hierarchically and shows
them as a set of nested rectangles. It represents the data graphically which
uses multiple colors to represent different values. It is used for comparing
the categories with colors, size, and it can also be used for illustrating the
hierarchical data and part to whole relationships. It is used for comparing the
categories based on color and size. And also it is great in spotting the
patterns based on the density of the information. The colors and size of
rectangles are respective to the values of the data points When their values
are higher or density of records, the data will represent in dark color.<o:p></o:p></span></p><p class="MsoNormal" style="background: white; line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3;"><b><span style="font-family: "Open Sans", sans-serif; font-size: 13.5pt;">Define some ways to improve the performance of
Tableau<o:p></o:p></span></b></p><ul type="disc">
<li class="MsoNormal" style="background: white; line-height: 200%;"><span style="font-family: "Open Sans",sans-serif; font-size: 11.5pt; line-height: 200%; mso-fareast-font-family: "Times New Roman";">Use
an Extract to make workbooks run faster<o:p></o:p></span></li>
<li class="MsoNormal" style="background: white; line-height: 200%;"><span style="font-family: "Open Sans",sans-serif; font-size: 11.5pt; line-height: 200%; mso-fareast-font-family: "Times New Roman";">Reduce
the scope of data to decrease the volume of data<o:p></o:p></span></li>
<li class="MsoNormal" style="background: white; line-height: 200%;"><span style="font-family: "Open Sans",sans-serif; font-size: 11.5pt; line-height: 200%; mso-fareast-font-family: "Times New Roman";">Reduce
the number of marks on the view to avoid information overload<o:p></o:p></span></li>
<li class="MsoNormal" style="background: white; line-height: 200%;"><span style="font-family: "Open Sans",sans-serif; font-size: 11.5pt; line-height: 200%; mso-fareast-font-family: "Times New Roman";">Try
to use integers or Booleans in calculations as they are much faster than
strings<o:p></o:p></span></li>
<li class="MsoNormal" style="background: white; line-height: 200%;"><span style="font-family: "Open Sans",sans-serif; font-size: 11.5pt; line-height: 200%; mso-fareast-font-family: "Times New Roman";">Hide
unused fields<o:p></o:p></span></li>
<li class="MsoNormal" style="background: white; line-height: 200%;"><span style="font-family: "Open Sans",sans-serif; font-size: 11.5pt; line-height: 200%; mso-fareast-font-family: "Times New Roman";">Use
Context filters<o:p></o:p></span></li>
<li class="MsoNormal" style="background: white; line-height: 200%;"><span style="font-family: "Open Sans",sans-serif; font-size: 11.5pt; line-height: 200%; mso-fareast-font-family: "Times New Roman";">Reduce
filter usage and use some alternative way to achieve the same result<o:p></o:p></span></li>
<li class="MsoNormal" style="background: white; line-height: 200%;"><span style="font-family: "Open Sans",sans-serif; font-size: 11.5pt; line-height: 200%; mso-fareast-font-family: "Times New Roman";">Use
indexing in tables and use the same fields for filtering<o:p></o:p></span></li>
<li class="MsoNormal" style="background: white; line-height: 200%;"><span style="font-family: "Open Sans",sans-serif; font-size: 11.5pt; line-height: 200%; mso-fareast-font-family: "Times New Roman";">Remove
unnecessary calculations and sheets<o:p></o:p></span></li>
</ul><h3 style="background: white;"><span style="font-family: "Open Sans", sans-serif;">Define Dual-axis?<o:p></o:p></span></h3><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">Dual-axis is used to show 2 measures in a single graph. It allows
you to compare 2 measures at once. <o:p></o:p></span></p><h3 style="background: white;"><span style="font-family: "Open Sans", sans-serif;">What is context filters in Tableau?<o:p></o:p></span></h3><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">Whenever we set a context filter, Tableau generates a temp table
that needs to refresh each and every time, whenever the view is triggered. So,
if the context filter is changed in the database, it needs to recompute the
temp table, so the performance will be decreased.<o:p></o:p></span></p><h3 style="background: white;"><span style="font-family: "Open Sans", sans-serif;">Define LOD Expression?</span><o:p></o:p></h3><p style="background: white; box-sizing: border-box; overflow-wrap: break-word !important;"><span style="font-family: "Open Sans", sans-serif; font-size: 11.5pt;">LOD Expression stands for Level of Detail Expression, and it is
used to run complex queries involving many dimensions at the data sourcing
level.<o:p></o:p></span></p><p>
</p><p class="MsoNormal"><o:p> </o:p></p>Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com0tag:blogger.com,1999:blog-1347602528429387759.post-42368967522961465612021-10-28T07:43:00.000-07:002021-10-28T07:43:04.295-07:00Tableau - Create Custom Color Palettes<p><span style="font-family: arial;">Tableau provides several color options to visualize the data into different chart forms where a lot of color options are available already and if we need to add more colors then we can customize the color palettes where <span style="color: #333333;">Tableau Desktop comes with color palettes that have been carefully designed to work well together and effectively apply color to data in many situations, such as on maps, heat maps, bar charts, etc. You can also create and use your own custom color palettes by modifying the </span><span class="uicontrol" style="box-sizing: inherit; color: #333333; font-weight: 700;">Preferences.tps</span><span style="color: #333333;"> file that comes with Tableau Desktop.</span></span></p><p><span style="font-family: arial;"><span style="color: #333333;">The </span><span class="uicontrol" style="box-sizing: inherit; color: #333333; font-weight: 700;">Preferences.tps</span><span style="color: #333333;"> </span><span style="color: #333333;">file is located in your My Tableau Repository. The file is a basic XML file that you can open in a text editor to modify. An unedited preferences file looks like this:</span></span></p><p style="box-sizing: inherit; color: #333333;"><span style="font-family: arial;"><img alt="" src="https://help.tableau.com/current/pro/desktop/en-us/Img/custom_color4.png" style="border-style: none; box-sizing: inherit; max-width: 100%;" /></span></p><p style="box-sizing: inherit; color: #333333;"><span style="font-family: arial;">we can add as many custom palettes as you like to your <span class="uicontrol" style="box-sizing: inherit; font-weight: 700;">Preferences.tps</span> file, each with as many colors as you want. When we modify <span class="uicontrol" style="box-sizing: inherit; font-weight: 700;">Preferences.tps</span> to add colors, use the standard HTML format for the new colors (hexadecimal value #RRGGBB or Red Green Blue format). When you save the workbook and restart Tableau Desktop, the color palette names you added to <span class="uicontrol" style="box-sizing: inherit; font-weight: 700;">Preferences.tps</span> appear in the <span class="uicontrol" style="box-sizing: inherit; font-weight: 700;">Select Color Palette</span> drop-down list (Edit Color dialog). You can use a new palette like you would any other.</span></p><p style="box-sizing: inherit; color: #333333;"><span style="font-family: arial;">Tableau doesn't test or support custom color palettes, so be sure to back up your workbooks before you continue. Also, there is no guarantee that custom color palettes you create will work with future Tableau Desktop upgrades.</span></p><p style="box-sizing: inherit; color: #333333;"></p><div style="box-sizing: inherit;"></div><p></p><p class="note" style="-webkit-text-stroke-width: 0px; background-color: #ebebeb; border-radius: 0.3rem; box-sizing: inherit; color: #333333; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; margin: 1.6rem 0px; orphans: 2; padding: 1.6rem; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="font-family: arial;">When you edit your<span> </span><span class="uicontrol" style="box-sizing: inherit; font-weight: 700;">Preferences.tps</span><span> </span>file, be sure to use straight quotation marks (<code style="background: transparent; box-sizing: inherit;">' '</code><span> </span>or<span> </span><code style="background: transparent; box-sizing: inherit;">" "</code>) to delimit the palette name and type, not curly quotation marks (“ ” or ‘ ’).</span></p><p style="box-sizing: inherit; color: #333333;"><span style="box-sizing: inherit; font-weight: bolder;"><span style="font-family: arial;">To edit your preferences file:</span></span></p><ol style="box-sizing: inherit; color: #333333;"><li style="box-sizing: inherit;" value="1"><p style="box-sizing: inherit;"><span style="font-family: arial;">Go to the My Tableau Repository folder in your Documents directory, and open the <span style="box-sizing: inherit; font-weight: bolder;">Preferences.tps</span> file.</span></p></li><li style="box-sizing: inherit;" value="2"><p style="box-sizing: inherit;"><span style="font-family: arial;">Between the opening and closing <code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; box-sizing: inherit;">workbook</code> tags, insert opening and closing <code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; box-sizing: inherit;">preferences</code> tags.</span></p></li></ol><p style="box-sizing: inherit; color: #333333;"><span style="font-family: arial;"><img alt="" src="https://help.tableau.com/current/pro/desktop/en-us/Img/custom_color11.png" style="border-style: none; box-sizing: inherit; max-width: 100%;" /></span></p><p style="box-sizing: inherit; color: #333333;"><span style="font-family: arial;">For more options to modify the preferences file:</span></p><p style="box-sizing: inherit;"><span style="color: #333333; font-family: arial;"><a href="https://help.tableau.com/current/pro/desktop/en-us/formatting_create_custom_colors.htm">https://help.tableau.com/current/pro/desktop/en-us/formatting_create_custom_colors.htm</a></span></p><p style="box-sizing: inherit;"><span style="color: #333333; font-family: Merriweather, Georgia, serif;"><br /></span></p>Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com0tag:blogger.com,1999:blog-1347602528429387759.post-32560513658543854362021-10-28T07:14:00.002-07:002021-10-28T07:14:37.141-07:00Query to find all the Stored Procedures (SP) which are related to one or more specific tables.<p>In some scenarios, we need to identify the dependency of particular tables for stored procedures.</p><p>The below query <span style="background-color: white; color: #363b3f; font-family: "Open Sans", sans-serif; font-size: 14px; text-align: justify;">will help to find all the Stored Procedures (SP) which are related to one or more specific tables.</span></p><p style="text-align: justify;"><span style="color: #363b3f; font-family: Open Sans, sans-serif;"><span style="font-size: 14px;">----Option 1</span></span></p><p style="text-align: justify;"><span style="color: #363b3f; font-family: Open Sans, sans-serif;"><span style="font-size: 14px;">SELECT DISTINCT so.name</span></span></p><p style="text-align: justify;"><span style="color: #363b3f; font-family: Open Sans, sans-serif;"><span style="font-size: 14px;">FROM syscomments sc</span></span></p><p style="text-align: justify;"><span style="color: #363b3f; font-family: Open Sans, sans-serif;"><span style="font-size: 14px;">INNER JOIN sysobjects so ON sc.id=so.id</span></span></p><p style="text-align: justify;"><span style="color: #363b3f; font-family: Open Sans, sans-serif;"><span style="font-size: 14px;">WHERE sc.TEXT LIKE '%TableName%'</span></span></p><p style="text-align: justify;"><span style="color: #363b3f; font-family: Open Sans, sans-serif;"><span style="font-size: 14px;"><br /></span></span></p><p style="text-align: justify;"><span style="color: #363b3f; font-family: Open Sans, sans-serif;"><span style="font-size: 14px;">----Option 2</span></span></p><p style="text-align: justify;"><span style="color: #363b3f; font-family: Open Sans, sans-serif;"><span style="font-size: 14px;">SELECT DISTINCT o.name, o.xtype</span></span></p><p style="text-align: justify;"><span style="color: #363b3f; font-family: Open Sans, sans-serif;"><span style="font-size: 14px;">FROM syscomments c</span></span></p><p style="text-align: justify;"><span style="color: #363b3f; font-family: Open Sans, sans-serif;"><span style="font-size: 14px;">INNER JOIN sysobjects o ON c.id=o.id</span></span></p><p><span style="color: #363b3f; font-family: Open Sans, sans-serif;"><span style="background-color: white; font-size: 14px; text-align: justify;"></span></span></p><p style="text-align: justify;"><span style="color: #363b3f; font-family: Open Sans, sans-serif;"><span style="font-size: 14px;">WHERE c.TEXT LIKE '%TableName%'</span></span></p>Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com2tag:blogger.com,1999:blog-1347602528429387759.post-76812477853297143462021-09-27T10:19:00.000-07:002021-09-27T10:19:01.566-07:00Mostly asked Tableau Interview questions for Beginner and experienced professionals<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal;"><br /></span></h1><h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal;"><span style="color: #666666;">Below are mostly asked Tableau questions for the interview which will help you to stand out in your Tableau interview and to get the best jobs as a Tableau Developer, Tableau Solution Architect, Tableau Analyst, etc.</span></span></h1><h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">What
are different Tableau products?<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">What is Tableau Data extract in Tableau?<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">Data Joining techniques in Tableau?<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">What is the Difference Between Joining and
Blending?<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">What are measures and dimensions?<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">What are continuous and discrete field types?<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">What are the different types of joins in
Tableau?<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">What are<span style="background: white;"> data
connections in Tableau?<o:p></o:p></span></span></h1>
<h1><span style="font-weight: normal;"><span style="border: 1pt none windowtext; font-family: "Arial Narrow", sans-serif; font-size: 14pt; line-height: 107%; padding: 0in;">What is a blended axis?</span><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; line-height: 107%;"><o:p></o:p></span></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">How to create a donut chart in a tableau?<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">What is the difference between a tree and a heat map?<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">What are extracts and Schedules in the Tableau
server?<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">What is a TDE file in Tableau?<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">How Can You Display the Top Five and Bottom
Five Sales in the Same View?<o:p></o:p></span></h1>
<h1><span style="font-weight: normal;"><span style="border: 1pt none windowtext; font-family: "Arial Narrow", sans-serif; font-size: 14pt; line-height: 107%; padding: 0in;">What is the difference between a TWB and a
TWBX file?</span><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; line-height: 107%;"><o:p></o:p></span></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">Approach to increase Performance in Tableau?<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">What is Hierarchy?<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">Table Calculation – Running Total,
Percentile?<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">What is a User filter? <o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">How to Implement Row-level security?<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">What are Groups and how do they differ from sets?<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">What type of filters is in the tableau? Table,
Context, Extract, Data Source, Dimension, and Measure<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">How to set alternate row background color in
tableau?<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">What is the Use of Dual-axis?<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">Have u developed calculated fields in
tableau? what will be the expression to get the month name from the order date which is
9/2/2020?<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">What are the differences between Dashboard and
Story in tableau?<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">What is the LOD function? Any example where u
have applied LOD function?<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">How Can You Embed a Web Page in a Dashboard?<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">What is the Datetrunc function in Tableau?<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;">how to customize the color palette in tableau?<o:p></o:p></span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;"> -----------------------------------------------------------------------------------------</span></h1><div><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt;"><span style="color: #ffa400;">Stay tuned for more real-time interview questions!</span></span></div><div><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;"><span style="color: #ffa400;"><br /></span></span></div><div><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;"><span style="color: #ffa400;">Thanks!</span></span></div>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;"> </span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;"> </span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;"> </span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;"> </span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;"> </span></h1>
<h1><span style="font-family: "Arial Narrow", sans-serif; font-size: 14pt; font-weight: normal; line-height: 107%;"> </span></h1><p> </p>Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com1tag:blogger.com,1999:blog-1347602528429387759.post-68578766164213753472021-09-26T08:07:00.005-07:002021-09-26T08:11:48.790-07:00Mostly Asked Interview Questions For Data Engineer, Data Analyst, BI Engineer and Data Science<p> Most Asked Interview Questions For Data Engineer, Data Analyst, BI Engineer, and Data Science</p><p>In this post, I am sharing a list of the most asked questions in the interview for Data Engineer, Data Analyst, BI Engineer, and Data Science.</p><p>Must Read: <a href="http://bilearninghub.blogspot.com/2021/07/sql-server-day-to-day-mostly-used.html"><span style="font-size: medium;">SQL-server-day-today-mostly-used functions</span></a></p><p>- <b><u><a href="https://docs.microsoft.com/en-us/sql/t-sql/data-types/data-types-transact-sql?view=sql-server-ver15">Data Types</a></u></b>:</p><p><span><span> </span>Small Int</span></p><p><span> Int</span><br /></p><p><span><span> Big Int</span><br /></span></p><p><span><span> Float</span><br /></span></p><p><span><span><span> Decimal</span><br /></span></span></p><p><span><span><span><span> Money</span><br /></span></span></span></p><p><span><span><span><span> </span>Char</span></span></span></p><p><span><span><span><span> Varchar</span><br /></span></span></span></p><p><span><span><span><span><span> Nvarchar</span><br /></span></span></span></span></p><p><span><span><span><span><span><span> Text</span><br /></span></span></span></span></span></p><p><span><span><span><span><span><span><span> Binary</span><br /></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span> Image</span><br /></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span> </span></span></span></span></span></span></span></span></span>Date</p><p><span> DateTime</span><br /></p><p><span><span><span><span><span><span><span> Timestamp</span><br /></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span> Bit</span><br /></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span>- <a href="https://docs.microsoft.com/en-us/sql/t-sql/functions/functions?view=sql-server-ver15#rowset-functions">Functions</a>:</span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span> <u><a href="http://bilearninghub.blogspot.com/2021/07/sql-server-day-to-day-mostly-used.html">Scalar Functions:</a></u> </span></span></span></span></span></span></span></span><span face=""Segoe UI", SegoeUI, "Helvetica Neue", Helvetica, Arial, sans-serif" style="background-color: white; color: #171717; font-size: 16px;">Operate on a single value and then return a single value. Scalar functions can be used wherever an expression is valid.</span></p><p><span><span><span><span><span><span><span><span><span><span> </span><span> </span></span></span></span></span></span></span></span></span></span>UCASE()</p><p><span> </span><span> </span>LCASE()</p><p><span> </span><span> </span>MID()</p><p><span> </span><span> </span>LEN()</p><p><span> </span><span> </span>ROUND()</p><p><span> </span><span> </span>NOW()</p><p><span> </span><span> </span>FORMAT()</p><p><span><span><span><span><span><span><span><span><span> <u><a href="http://bilearninghub.blogspot.com/2021/07/sql-server-day-to-day-mostly-used.html">Aggregate Functions:</a></u> </span></span></span></span></span></span></span></span></span><span face=""Segoe UI", SegoeUI, "Helvetica Neue", Helvetica, Arial, sans-serif" style="background-color: white; color: #171717; font-size: 16px;">Aggregate functions perform a calculation on a set of values and return a single value.</span></p><p><span><span><span><span><span><span><span><span><span><span><span> </span><span> Min</span><br /></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span> </span><span> Max</span><br /></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span> </span><span> Avg</span><br /></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span> </span><span> Count</span><br /></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span> </span><span> Sum</span><br /></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span> </span><span> Mod</span><br /></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span> </span><span> First</span><br /></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span> </span><span> Last</span><br /></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span> <a href="http://bilearninghub.blogspot.com/2021/07/sql-server-day-to-day-mostly-used.html"><u>Analytical Functions:</u> </a></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span face=""Segoe UI", SegoeUI, "Helvetica Neue", Helvetica, Arial, sans-serif" style="background-color: white; color: #171717; font-size: 16px;">Analytic functions compute an aggregate value based on a group of rows.</span></p><p><span face=""Segoe UI", SegoeUI, "Helvetica Neue", Helvetica, Arial, sans-serif" style="background-color: white; color: #171717; font-size: 16px;"><span> <span> </span> </span></span><span face="Segoe UI, SegoeUI, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #171717;">First_Value</span></p><p><span face="Segoe UI, SegoeUI, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #171717;"><span> <span> </span></span>Last_Value</span></p><p><span face="Segoe UI, SegoeUI, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #171717;"><span> <span> </span></span>LAG</span></p><p><span face="Segoe UI, SegoeUI, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #171717;"><span> <span> </span></span>Lead</span></p><p><span face="Segoe UI, SegoeUI, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #171717;"><span> <span> </span></span>Percentile_Cont</span></p><p><span face="Segoe UI, SegoeUI, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #171717;"><span> <span> </span></span>Percentile_Disc</span></p><p><span face="Segoe UI, SegoeUI, Helvetica Neue, Helvetica, Arial, sans-serif" style="color: #171717;"><span> <span> </span></span>Percentile_Rank</span></p><p> <a href="http://bilearninghub.blogspot.com/2021/07/sql-server-day-to-day-mostly-used.html"> </a><a href="http://bilearninghub.blogspot.com/2021/07/sql-server-day-to-day-mostly-used.html"><u>Ranking Function:</u> </a><span face=""Segoe UI", SegoeUI, "Helvetica Neue", Helvetica, Arial, sans-serif" style="background-color: white; color: #171717; font-size: 16px;">Ranking functions return a ranking value for each row in a partition.</span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span> </span><span> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>Rank<span> </span></p><p><span> </span><span> </span>Row_Number</p><p><span> </span><span> </span>Dense_Rank</p><p><span> </span><span> </span>NILE</p><p><span> </span><a href="http://bilearninghub.blogspot.com/2021/07/sql-server-day-to-day-mostly-used.html"><u>String Function</u>:</a> The string function return a value to perform some operations on the string value.</p><p><span> <span> </span>Substr</span><br /></p><p><span><span> </span><span> CharIndex</span><br /></span></p><p><span><span><span> </span><span> PatIndex</span><br /></span></span></p><p><span><span><span><span> </span><span> Replace</span><br /></span></span></span></p><p><span><span><span><span><span> </span><span> Left</span><br /></span></span></span></span></p><p><span><span><span><span><span><span> </span><span> Right</span><br /></span></span></span></span></span></p><p><span><span><span><span><span><span><span> </span><span> LTrim</span><br /></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span> </span><span> RTrim</span><br /></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span> </span><span> Len</span><br /></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><a href="http://bilearninghub.blogspot.com/2021/07/sql-server-day-to-day-mostly-used.html"><u>Date Functions</u>:</a> Date functions are used to perform some operations on the date value.</span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span> DateAdd</span><br /></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span> DateDiff</span><br /></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span> DatePart</span><br /></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span> DateName</span><br /></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span> Year</span><br /></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span> Month</span><br /></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span> Getdate()</span><br /></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span>- What is @@Error?</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span>- Difference between DDL, DML, and DCL.</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span>- What type of clause in SQL?</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span> Ans: Where, Group BY, Order By</span><br /></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span>- What is Constraint in SQL?</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span>- Difference between Temp variable, Temp Table?</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span>- Difference between Local Temporary Tables and Global Temporary Tables?</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span>- How we can schedule a job in SQL Server?</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span> Ans: SQL Server Agent</span><br /></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span>- What is NOLock?</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span>- What type of joins do we have in SQL?</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p>- What are Logical Joins and Physical Joins?</p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span>- Difference between Inner Join and Left Join?</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span>- What is Cross Join?</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span>- What are Cross Apply and Outer Apply?</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p>- Difference between Functions and Stored Procedure?</p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span>- Difference between the Delete table and the Truncate table?</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span>- Difference between Varchar() and Nvarchar()?</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span>- Difference between Cast and Convert?</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span>- Difference between View and CTE?</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span>- What is Indexed View?</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span>- Can we Insert or update in views?</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span>- What is Index in SQL and type of Indexes in SQL?</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span>- Difference between Primary Key, Foreign Key, and Unique Key?</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span>- What is Database Partitioning?</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span>- What are Triggers in Database?</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span>- What is Window Functions?</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p>- Difference between Having and Group By?</p><p>- What is an Execution Plan?</p><p>- what are IN-memory Tables?</p><p>- What is Always on?</p><p>- What Is Data Encryption?</p><p>- What is the difference between ISNULL, NVL, and Coalesce?</p><p>Scenarios based Questions:</p><p>- How to improve the performance of slow-running queries?</p><p>OR</p><p>- Define approaches to tune the queries and improve the performance?</p><p>- How to calculate the running total?</p><p>- Find 3rd highest salary from the employee table?</p><p>- From the employee table, show the manager of each employee?</p><p>- Implementation of Joins for a given data</p><p>- How to remove duplicates from the table?</p><p>- How do get the latest order for each customer?</p><p>- Show highest-paid and Lowest paid employee from each Department</p><p>- Top five highest selling products from each product category in past one quarter?</p><p><br /></p><p>Stay tuned for more details.</p><p>Thanks for your visit!</p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><br /></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><br /></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span> </span><br /></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span><span><span><span><span><span><br /></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><br /></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span> </span><span> </span><br /></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span><span> </span><br /></span></span></span></span></span></span></span></span></span></p><p><span><span><span><span><span><span><span><span><span> </span><br /></span></span></span></span></span></span></span></span></p><p><span><span><br /></span></span></p><p><br /></p>Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com0tag:blogger.com,1999:blog-1347602528429387759.post-47833400967528714612021-07-23T10:21:00.001-07:002021-07-23T10:21:29.407-07:00SQL Server day-to-day mostly used functions - String, Aggregate, Window, Date Functions in SQL<p style="text-align: center;"> <u style="text-align: center;"><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">SQL Server day-to-day mostly used functions - String, Aggregate, Window, Date Functions in SQL</span></u></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">CAST()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This function is used to <span style="background: white;">convert an expression of one data type to another. The
CAST function is used to convert a data type without a specific format.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="background: white; font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax – CAST(Coulmn_Name, Data_Type)<o:p></o:p></span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in; text-indent: 0.5in;"><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">SELECT CAST(1234, INT)</span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">CONVERT()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – <span style="background: white;">This function is used to convert and formatting data types at the same time.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="background: white; font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax – CONVERT(Data_Type ,Coulmn_Name, Format_TYPE)<o:p></o:p></span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in; text-indent: 0.5in;"><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">SELECT CONVERT(Varchar,GateDate(), 111) FROM Table_Name</span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">SUBSTR()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – <span style="background: white;">This function
extracts a substring from a string (starting at any position).<o:p></o:p></span></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="background: white; font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax </span></span><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">– <span class="sqlkeywordcolor">SELECT</span> SUBSTRING(<span class="sqlstringcolor">‘ABCDEF'</span>, <span class="sqlnumbercolor">1</span>, <span class="sqlnumbercolor">3</span>)</span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">STUFF()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – <span style="background: white;">The <em><span style="font-style: normal;">STUFF</span></em> function
inserts a string into another string. It deletes a specified length of
characters in the first string at the start position</span>.<o:p></o:p></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax – <span class="hljs-keyword">SELECT</span> <span class="hljs-keyword">STUFF</span>(<span class="hljs-string">'ABCDEF'</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-string">'IJKL'</span>)</span><span style="background: white;"><o:p></o:p></span></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">REPLACE()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This function is used to replace an existing <span style="background: white;">specified string value with another string value</span>
of all occurrence.<o:p></o:p></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax – <span class="hljs-keyword">SELECT</span> <span class="hljs-keyword">REPLACE</span>(<span class="hljs-string">'ABCDEFGHI'</span>,<span class="hljs-string">'EFG'</span>,<span class="hljs-string">'LMN'</span>)</span><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">RTRIM()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – <span style="background: white;">This function removes trailing spaces from a string from the right side.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax – SELECT RTRIM<span class="grcorrect">(</span>' ABCDEF ')</span><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">LTRIM()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> - <span style="background: white;">This
function removes trailing spaces from a string from the left side.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="background: white; font-size: 12pt; line-height: 107%;"> </span><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">Syntax – SELECT LTRIM<span class="grcorrect">(</span>' ABCDEF ')</span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">LEFT()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This Function <span style="background: white;">extracts a number of characters from a string (starting from left)<o:p></o:p></span></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="background: white; font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax </span></span><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">– SELECT LTRIM<span class="grcorrect">(</span>'ABCDEF', 3)</span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">RIGHT()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This Function <span style="background: white;">extracts a number of characters from a string (starting from right).</span><o:p></o:p></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax – SELECT RIGHT<span class="grcorrect">(</span>'ABCDEF',3)</span><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">CHARINDEX()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This Function is <span style="background: white;">used to searches for a substring in a string and returns the position.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="background: white; font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax </span></span><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">– SELECT
(CHARINDEX('CDEF', 'ABCDEFGH'))</span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">PATINDEX()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This Function is <span style="background: white;">used to get starting position of a pattern by using wild characters in
the pattern.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="background: white; font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax </span></span><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">– SELECT
(PATINDEX('%CDEF%', 'ABCDEFGH'))</span><span face="Arial, sans-serif" style="background: white; font-size: 12pt; line-height: 107%;"> </span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">ISNULL()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This <span style="background: white;">function
is used to specify how we want to treat NULL values.<o:p></o:p></span></span></p>
<p class="MsoNormal" style="text-indent: 0.5in;"><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">Syntax </span><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">– SELECT ISNULL(Column_Name, Specified_value) FROM Table_Name</span><span face="Arial, sans-serif" style="background: white; font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">COALESCE()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This function is used to handle null value
from multiple arguments, <span style="background: white;">and always returns <em><span style="border: 1pt none windowtext; padding: 0in;">first non-null</span></em> value. <span style="letter-spacing: 0.1pt;"> </span></span> <o:p></o:p></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax – SELECT COALESCE( NULL, ‘ABC’, ‘DEF’)</span><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">NVL()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This Function <span style="background: white;">converts a null value to an actual value. Data types that can be used
are date, character, and number.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="background: white; font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax – SELECT NVL(ColumnValue, 0)</span></span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">UCASE()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This function is used to convert the
column value into upper case.<o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent: 0.5in;"><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">Syntax </span><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">– SELECT UCASE(Column_Name) FROM Table_Name</span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">LCASE()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This function is used to convert the
column value into lower case.<o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent: 0.5in;"><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">Syntax </span><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">– SELECT LCASE(Column_Name) FROM Table_Name</span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">MID()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This Function <span style="background: white;">extracts a substring from a string (starting at any position).<o:p></o:p></span></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="background: white; font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax </span></span><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">– <span class="sqlkeywordcolor">SELECT</span> MID(<span class="sqlstringcolor">‘ABCDEFGH’</span>, <span class="sqlnumbercolor">4</span>, <span class="sqlnumbercolor">3</span>)</span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">LEN()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This function <span style="background: white;">calculates the number of characters of an input string.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="background: white; font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax – SELECT LEN(‘ABCDEFGH’)</span></span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">ROUND()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This Function <span style="background: white;">rounds a number to a specified number of decimal places.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="background: white; font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax – SELECT ROUND (12345.6789, 2)</span></span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">AVG()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – <span style="background: white;">This function
returns the average value of a numeric column.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="background: white; font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax </span></span><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">– SELECT
AVG(Column_Name) FROM Table_Name</span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">COUNT()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – <span style="background: white;">This function returns the number of rows. <o:p></o:p></span></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="background: white; font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax </span></span><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">– SELECT
COUNT(Column_Name) FROM Table_Name</span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">FIRST()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – <span style="background: white;">This function
returns the first value of the selected column.<o:p></o:p></span></span></p>
<p class="MsoNormal" style="text-indent: 0.5in;"><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">Syntax </span><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">– SELECT FIRST(Column_Name) FROM Table_Name</span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">LAST()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – <span style="background: white;">This
function returns the first value of the selected column.<o:p></o:p></span></span></p>
<p class="MsoNormal" style="text-indent: 0.5in;"><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">Syntax </span><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">– SELECT FIRST(Column_Name) FROM Table_Name</span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">MAX()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This function returns the maximum value of the
selected column.<o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent: 0.5in;"><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">Syntax </span><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">– SELECT MAX(Column_Name) FROM Table_Name</span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">MIN()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This function returns the minimum value of the
selected column.<o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent: 0.5in;"><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">Syntax </span><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">– SELECT MIN(Column_Name) FROM Table_Name</span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">SUM()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This function returns aggregated sum value
of the selected column.<o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent: 0.5in;"><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">Syntax </span><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">– SELECT SUM(Column_Name) FROM Table_Name</span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">LEG()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – Lead and Leg are called WINDOW functions
as well, <span style="background: white; letter-spacing: 0.1pt;">are used to get preceding
and succeeding value of any row within its partition. The LAG() function is used
to get value from the row that precedes the current row.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="background: white; font-size: 12pt; letter-spacing: 0.1pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax – Select </span></span><code><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">LAG(sale_value) OVER(ORDER</span></code><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;"> </span><code><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">BY</span></code><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;"> </span><code><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">sale_value) as</span></code><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;"> </span><code><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">previous_sale_value From SalesTable</span></code><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">LEAD()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – <span style="background: white; letter-spacing: 0.1pt;">The LEAD() function is used to get value from row that
succedes the current row.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="background: white; font-size: 12pt; letter-spacing: 0.1pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax </span></span><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">– <span style="letter-spacing: 0.1pt; mso-shading: white;">Select </span><code><span face=""Arial",sans-serif" style="line-height: 107%; mso-ansi-font-size: 12.0pt; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;">LEAD(sale_value) OVER(ORDER</span></code> <code><span face=""Arial",sans-serif" style="line-height: 107%; mso-ansi-font-size: 12.0pt; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;">BY</span></code> <code><span face=""Arial",sans-serif" style="line-height: 107%; mso-ansi-font-size: 12.0pt; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;">sale_value)
as</span></code> <code><span face=""Arial",sans-serif" style="line-height: 107%; mso-ansi-font-size: 12.0pt; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;">Next_sale_value From SalesTable</span></code></span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">RANK()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – <span style="background: white;">Ranking
functions return a ranking value for each row in a partition. <o:p></o:p></span></span></p>
<p class="MsoNormal" style="text-indent: 0.5in;"><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">Syntax – Select <span class="crayon-e"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">RANK</span></span><span class="crayon-sy"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">()</span></span><span class="crayon-h"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span class="crayon-k"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">OVER</span></span><span class="crayon-sy"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">(</span></span><span class="crayon-i"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">PARTITION</span></span><span class="crayon-h"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span class="crayon-k"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">BY</span></span><span class="crayon-h"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span class="crayon-i"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">Column_Name</span></span><span class="crayon-h"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span class="crayon-k"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">ORDER</span></span><span class="crayon-h"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span class="crayon-k"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">BY</span></span><span class="crayon-h"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span class="crayon-i"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">Column_Name</span></span><span class="crayon-h"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span class="crayon-k"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">DESC</span></span><span class="crayon-sy"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">)</span></span><span class="crayon-h"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span class="crayon-i"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">Rank From Table_Name</span></span></span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">ROW_NUMBER()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – <span style="background: white;">This
function to get a unique sequential number for each row in the specified data.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="background: white; font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax – Select <span class="crayon-e"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">ROW_NUMBER</span></span><span class="crayon-sy"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">()</span></span><span class="crayon-h"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span class="crayon-k"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">OVER</span></span><span class="crayon-sy"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">(</span></span><span class="crayon-k"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">ORDER</span></span><span class="crayon-h"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span class="crayon-k"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">BY</span></span><span class="crayon-h"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span class="crayon-i"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">Column_Name</span></span><span class="crayon-sy"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">)</span></span><span class="crayon-h"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span class="crayon-i"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">RowNumber From Table_Name</span></span></span></span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">DENSE_RANK()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This <span style="background: white;">function
to specify a unique rank number within the partition as per the specified
column value. <o:p></o:p></span></span></p>
<p class="MsoNormal" style="text-indent: 0.5in;"><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">Syntax – Select <span class="crayon-e"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">DENSE_RANK</span></span><span class="crayon-sy"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">()</span></span><span class="crayon-h"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span class="crayon-k"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">OVER</span></span><span class="crayon-sy"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">(</span></span><span class="crayon-k"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">ORDER</span></span><span class="crayon-h"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span class="crayon-k"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">BY</span></span><span class="crayon-h"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span class="crayon-i"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">Column_Name</span></span><span class="crayon-sy"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">)</span></span><span class="crayon-h"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;"> </span></span><span class="crayon-i"><span style="border: 1pt none windowtext; mso-border-alt: none windowtext 0in; padding: 0in;">DenseRank From Table_Name</span></span></span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">DATEDIFF()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This function returns the difference
between two dates based on argument value for Day, Month, and Year.<o:p></o:p></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax – SELECT
DATEDIFF(YEAR, ‘01/01/2011’, ‘01/01/2021, )</span><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">DATEADD()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This Function <span style="background: white;">adds a time/date interval to date and then returns the date.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="background: white; font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax </span></span><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">– <span class="sqlkeywordcolor">SELECT</span> DATEADD(year, <span class="sqlnumbercolor">1</span>, <span class="sqlstringcolor">'01/01/2021’</span>)</span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">DATEPART()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This function <span style="background: white;">returns an integer representing the specified <em><span style="font-style: normal;">datepart</span></em><i> </i>of
the specified <em><span style="font-style: normal;">date.</span></em><em><o:p></o:p></em></span></span></p>
<p class="MsoNormal"><em><span face="Arial, sans-serif" style="background: white; font-size: 12pt; line-height: 107%;"> </span></em><em><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; font-style: normal; line-height: 107%;">Syntax </span></em><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">– <span class="sqlkeywordcolor">SELECT</span> DATEPART(year, <span class="sqlstringcolor">'01/01/2021’</span>)</span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">DATENAME()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This function <span style="background: white;">returns a character string representing the specified <em><span style="font-style: normal;">datepart</span></em> of
the specified <em><span style="font-style: normal;">date</span></em></span><o:p></o:p></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax – <span class="sqlkeywordcolor">SELECT</span> DATENAME(Month, <span class="sqlstringcolor">'01/01/2021’</span>)</span><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">GETDATE()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This function returns the current date and time
of the system/server, <span style="background: white;">in a 'YYYY-MM-DD
hh:mm:ss.mmm' format.</span><o:p></o:p></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax –
SELECT GETDATE()</span><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">CURRENT_TIMESTAMP()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This Function also <span style="background: white;">returns the current date and time, in a 'YYYY-MM-DD hh:mm:ss.mmm' format.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="background: white; font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax – Select </span></span><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">CURRENT_TIMESTAMP</span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">FORMAT()</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This function <span style="background: white;">returns a value formatted with the specified format and optional culture,
mostly used for date format</span>.<o:p></o:p></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax – </span></span><span face="Arial, sans-serif" style="background: aqua; font-size: 12pt; line-height: 107%;">SELECT FORMAT(‘01/01/2021’,
'd', 'en-US' ) 'US English'</span><span face="Arial, sans-serif" style="background: rgb(242, 242, 242); font-size: 12pt; line-height: 107%;"> <o:p></o:p></span></p>
<p class="MsoNormal"><u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;">SYSTEM_USER</span></u><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> – This Function is used <span style="background: white;">to return the <em><span style="font-style: normal;">current user</span></em>name.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="background: white; font-size: 12pt; line-height: 107%;"> <span style="background: aqua; mso-highlight: aqua;">Syntax – Select SYSTEM_USER</span></span><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"><o:p></o:p></span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> </span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> </span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> </span></p>
<p class="MsoNormal"><span face="Arial, sans-serif" style="font-size: 12pt; line-height: 107%;"> </span></p>Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com0tag:blogger.com,1999:blog-1347602528429387759.post-45812386655233397482021-07-23T08:13:00.006-07:002021-07-23T08:13:43.618-07:00Types of Filters in Tableau<blockquote style="border: none; margin: 0 0 0 40px; padding: 0px;"><p class="MsoNormal" style="text-align: center;"><span style="font-family: "Arial",sans-serif; font-size: 12.0pt; line-height: 107%;"><b><u>Types of Filters in Tableau</u></b></span></p></blockquote><p class="MsoNormal"><span style="background: white; font-family: Arial, sans-serif; font-size: 12pt; line-height: 107%;">There
are different </span><span style="font-family: Arial, sans-serif; font-size: 12pt; line-height: 107%;">types of filters in a tableau that can be
used to organize data based on predefined conditions and use them
for visualizing the data onto the dashboard and worksheet. The
different types of filters used in Tableau are:</span></p><p class="MsoNormal"><span style="font-family: "Arial",sans-serif; font-size: 12.0pt; line-height: 107%;">1. Extract Filters<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family: "Arial",sans-serif; font-size: 12.0pt; line-height: 107%;">2. Data Source Filters<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family: "Arial",sans-serif; font-size: 12.0pt; line-height: 107%;">3. Context Filters<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family: "Arial",sans-serif; font-size: 12.0pt; line-height: 107%;">4. Dimension Filters<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family: "Arial",sans-serif; font-size: 12.0pt; line-height: 107%;">5. Measure Filters</span></p><p class="MsoNormal"><span style="font-family: Arial, sans-serif; font-size: 12pt;"><u>Extract Filters</u></span></p><p class="MsoNormal"><span style="font-family: "Arial",sans-serif; font-size: 12.0pt; line-height: 107%;">This is the initial level filter in Tableau. The Extract
filters in tableau create an extract of a small subset of data from the original data source or we can say that Extract filters are used to filter the
extracted data from the data source. This filter is utilized only if the user
extracts the data from the data source.<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family: "Arial",sans-serif; font-size: 12.0pt; line-height: 107%;"><u>Data Source Filters:</u><o:p></o:p></span></p><p class="MsoNormal"><span style="font-family: "Arial",sans-serif; font-size: 12.0pt; line-height: 107%;">As the name suggested, this filter applies to the data sources.
This filter any important or sensitive information that we want to control
while loading the data into Tableau. It works on both the Live and Extract
connections. We can add the data source filter on any column by clicking on the
ADD option.<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family: "Arial",sans-serif; font-size: 12.0pt; line-height: 107%;"><u>Context Filters</u><o:p></o:p></span></p><p class="MsoNormal"><span style="background: white; font-family: Arial, sans-serif; font-size: 12pt; line-height: 107%;">Context
filter is an independent filter that creates a different worksheet out of the
original dataset and computes the calculation in the filtered dataset.</span><span style="font-family: "Arial",sans-serif; font-size: 12.0pt; line-height: 107%;"> To
add a filter as a context in your Tableau sheet, right-click on the field value
in the filter pane and click on the Add to Context option. if we want to
remove any existing Context filter, then we can remove the context from the
same drop-down box.<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family: "Arial",sans-serif; font-size: 12.0pt; line-height: 107%;"><u>Dimension Filters</u><o:p></o:p></span></p><p class="MsoNormal"><span style="font-family: "Arial",sans-serif; font-size: 12.0pt; line-height: 107%;">When we apply a filter on the dimension it is called a
dimension filter. The dimension filters are the filters that we apply to
individual dimensions. Dimensions are not aggregated and so, we can select
distinct values from the list of field values. To apply the dimension filter,
drag a dimension from the list of dimensions to the filter pane. Complete the
filtering steps and apply the filter. The dimension filters are shown in blue
in the filter pane.<o:p></o:p></span></p><p class="MsoNormal"><span style="font-family: "Arial",sans-serif; font-size: 12.0pt; line-height: 107%;"><u>Measure Filters</u><o:p></o:p></span></p><p class="MsoNormal"><span style="background: white; font-family: Arial, sans-serif; font-size: 12pt; line-height: 107%;">Like
dimension filter we can also apply the filter on the measures. The measure
filters are the filters that we apply using the measure field values. Measure
values are always aggregated like sum, average, median, etc. To apply a measure
filter, drag a measure field from the measures list to the filter pane. It will
ask you to select an aggregation type on the filter value.</span><span style="font-family: "Arial",sans-serif; font-size: 12.0pt; line-height: 107%;"><o:p></o:p></span></p><p align="center" class="MsoNormal" style="text-align: center;">
</p><p class="MsoNormal"><span style="font-family: "Arial",sans-serif; font-size: 12.0pt; line-height: 107%;"> </span></p>Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com0tag:blogger.com,1999:blog-1347602528429387759.post-214815327358605272021-06-26T08:43:00.002-07:002021-06-26T08:43:09.756-07:00Tableau : Data Blending vs Data Joining - Differences between Data Blending and Data Joining<p><span style="font-family: arial;"> In Tableau, first step is to get data for building any visualization, where data can be from any source i.e. Relational database, DWH, CSV or Text file etc.. </span></p><p><span style="font-family: arial;">When we work with more then one data source then we need to implement relationship to integrate data from all sources for making any visualizations, so for this there are two techniques are available in Tableau which are majorly used for preparation of data for developing any visualization in Tableau:</span></p><p><b><span style="font-family: arial;"> - Data Blending </span></b></p><p><span style="font-family: arial;"><span> </span><span style="background-color: white; color: #202124; font-size: 16px;">Data Blending sounds similar to Join but it is not the same. Let us look at its usage:</span></span></p><p style="background: rgb(255, 255, 255); border: 0px; box-sizing: border-box; color: #202124; font-size: 16px; margin: 0px; outline: 0px; padding: 0px 0px 1em; text-size-adjust: 100%; vertical-align: baseline;"><span style="font-family: arial;">1. It should be used when you want to analyze data available in different sources.</span></p><ul style="background: rgb(255, 255, 255); border: 0px; box-sizing: border-box; color: #202124; font-size: 16px; line-height: 2em; list-style-image: initial; list-style-position: initial; margin: 0px; outline: 0px; padding: 0px 0px 23px 1em; text-size-adjust: 100%; vertical-align: baseline;"><li style="background: transparent; border: 0px; box-sizing: border-box; margin: 0px 0px 10px; outline: 0px; padding: 0px; text-size-adjust: 100%; vertical-align: baseline;"><span style="font-family: arial;">For example, Actual Sales for geography like Region Name can come from one source (relational) and Month details from a different source (Excel File).</span></li><li style="background: transparent; border: 0px; box-sizing: border-box; margin: 0px 0px 10px; outline: 0px; padding: 0px; text-size-adjust: 100%; vertical-align: baseline;"><span style="font-family: arial;">In case you wish to visualize monthly sales for a region, you will be using Data Blending.</span></li></ul><p style="background: rgb(255, 255, 255); border: 0px; box-sizing: border-box; color: #202124; font-size: 16px; margin: 0px; outline: 0px; padding: 0px 0px 1em; text-size-adjust: 100%; vertical-align: baseline;"><span style="font-family: arial;">2. Ensure that there is a common field called “Linking field” while performing Data Blending.</span></p><p style="background: rgb(255, 255, 255); border: 0px; box-sizing: border-box; color: #202124; font-size: 16px; margin: 0px; outline: 0px; padding: 0px 0px 1em; text-size-adjust: 100%; vertical-align: baseline;"><span style="font-family: arial;">3. Data Blending performs like a left join operation and does not accept or perform any other type of join.</span></p><p style="background: rgb(255, 255, 255); border: 0px; box-sizing: border-box; color: #202124; font-size: 16px; margin: 0px; outline: 0px; padding: 0px 0px 1em; text-size-adjust: 100%; vertical-align: baseline;"><span style="font-family: arial;">4. Since data is coming from different sources, it is not mandatory that both data sets have the same level of detail. Data blending operation is independent of granularity.</span></p><p><b><span style="font-family: arial;"> - Data Joining</span></b></p><ol style="background: rgb(255, 255, 255); border: 0px; box-sizing: border-box; color: #202124; font-size: 16px; line-height: 2em; list-style-image: initial; list-style-position: inside; margin: 0px; outline: 0px; padding: 0px 0px 23px; text-size-adjust: 100%; vertical-align: baseline;"><li style="background: transparent; border: 0px; box-sizing: border-box; margin: 0px 0px 10px; outline: 0px; padding: 0px; text-size-adjust: 100%; vertical-align: baseline;"><span style="font-family: arial;">It is primarily used when you have to merge data sets from the same source. For example, you want to look at Student details where his grades are coming from one source and personal information from another source. Here, the key will be the student roll number which will be unique.</span></li></ol><p style="background: rgb(255, 255, 255); border: 0px; box-sizing: border-box; color: #202124; font-size: 16px; margin: 0px; outline: 0px; padding: 0px 0px 1em; text-size-adjust: 100%; vertical-align: baseline;"><span style="font-family: arial;">There are different types of join;</span></p><p style="background: rgb(255, 255, 255); border: 0px; box-sizing: border-box; color: #202124; font-size: 16px; margin: 0px; outline: 0px; padding: 0px 0px 1em; text-size-adjust: 100%; vertical-align: baseline;"><span style="font-family: arial;"><span style="background: transparent; border: 0px; box-sizing: border-box; font-weight: 700; margin: 0px; outline: 0px; padding: 0px; text-size-adjust: 100%; vertical-align: baseline;">1. Inner Join - </span><span style="background: transparent; border: 0px; box-sizing: border-box; margin: 0px; outline: 0px; padding: 0px; text-size-adjust: 100%; vertical-align: baseline;">Unique matching data from both data input based on key relationship.</span></span></p><p style="background: rgb(255, 255, 255); border: 0px; box-sizing: border-box; color: #202124; font-size: 16px; margin: 0px; outline: 0px; padding: 0px 0px 1em; text-size-adjust: 100%; vertical-align: baseline;"></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBNkUyE-_aMc_9fWNvIx8RVBJ2qNbJu1d26LnrmkL_QbHfN12lFqnRYaJKARg1PUlrMPbRMxfrW4Wtf3fiYVlwrGzcss2HmLQRcdHs3GeHlreMQE2ROPbb5ko8IxSaZ1r7Sm1SkJBKLFk/s648/Inner+Join.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="371" data-original-width="648" height="116" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBNkUyE-_aMc_9fWNvIx8RVBJ2qNbJu1d26LnrmkL_QbHfN12lFqnRYaJKARg1PUlrMPbRMxfrW4Wtf3fiYVlwrGzcss2HmLQRcdHs3GeHlreMQE2ROPbb5ko8IxSaZ1r7Sm1SkJBKLFk/w203-h116/Inner+Join.PNG" width="203" /></a></div><br /><span style="background: transparent; border: 0px; box-sizing: border-box; font-family: arial; font-weight: 700; margin: 0px; outline: 0px; padding: 0px; text-size-adjust: 100%; vertical-align: baseline;">2. Left Join - </span><span style="background: transparent; border: 0px; box-sizing: border-box; font-family: arial; margin: 0px; outline: 0px; padding: 0px; text-size-adjust: 100%; vertical-align: baseline;">Full data from Left input data source and matching data from right data source </span><span style="font-family: arial;">based on key relationship.</span><p></p><p style="background: rgb(255, 255, 255); border: 0px; box-sizing: border-box; color: #202124; font-size: 16px; margin: 0px; outline: 0px; padding: 0px 0px 1em; text-size-adjust: 100%; vertical-align: baseline;"></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRN5aVCIDaGlBnC4Ro_fesovSZL9wC_VGOZKXHzHWT40e9xLeFraafvMWtz_51hPi5ahFcBDltitBa-qr1kF3FNr75sUwvwZpBDk6AmgLc2KkC9w3pjPgCIK_nGOkofY-RsWwjx1bF0oo/s651/Left+Join.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="375" data-original-width="651" height="116" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRN5aVCIDaGlBnC4Ro_fesovSZL9wC_VGOZKXHzHWT40e9xLeFraafvMWtz_51hPi5ahFcBDltitBa-qr1kF3FNr75sUwvwZpBDk6AmgLc2KkC9w3pjPgCIK_nGOkofY-RsWwjx1bF0oo/w202-h116/Left+Join.PNG" width="202" /></a></div><p></p><p style="background: rgb(255, 255, 255); border: 0px; box-sizing: border-box; color: #202124; font-size: 16px; margin: 0px; outline: 0px; padding: 0px 0px 1em; text-size-adjust: 100%; vertical-align: baseline;"><span style="font-family: arial;"><span style="background: transparent; border: 0px; box-sizing: border-box; font-weight: 700; margin: 0px; outline: 0px; padding: 0px; text-size-adjust: 100%; vertical-align: baseline;">3. Right Join - </span><span style="background: transparent; border: 0px; box-sizing: border-box; margin: 0px; outline: 0px; padding: 0px; text-size-adjust: 100%; vertical-align: baseline;">Full data from Right input data source and matching data from Left data source </span><span style="background-color: transparent;">based on key relationship.</span></span></p><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEoim7Q9bF13TTD8Qyf-czGb07xQWCMTSl5X-W4jxpEj-n3TeUFY_HoXhCIl3dy-U-gMXsjSrk6XK3pq7UW8_v-82p3adhmskjT6OnMP55W3nCDQrax01HPV8iUY5ldCpq1Rte07xVdWc/s636/Right+Join.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="363" data-original-width="636" height="117" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEoim7Q9bF13TTD8Qyf-czGb07xQWCMTSl5X-W4jxpEj-n3TeUFY_HoXhCIl3dy-U-gMXsjSrk6XK3pq7UW8_v-82p3adhmskjT6OnMP55W3nCDQrax01HPV8iUY5ldCpq1Rte07xVdWc/w203-h117/Right+Join.PNG" width="203" /></a></span></div><p></p><p style="background: rgb(255, 255, 255); border: 0px; box-sizing: border-box; color: #202124; font-size: 16px; margin: 0px; outline: 0px; padding: 0px 0px 1em; text-size-adjust: 100%; vertical-align: baseline;"><span style="font-family: arial;"><span style="background: transparent; border: 0px; box-sizing: border-box; font-weight: 700; margin: 0px; outline: 0px; padding: 0px; text-size-adjust: 100%; vertical-align: baseline;">4. Full Outer Join - </span>Result set from both the tables are merged and displayed.</span></p><p style="background: rgb(255, 255, 255); border: 0px; box-sizing: border-box; color: #202124; font-size: 16px; margin: 0px; outline: 0px; padding: 0px 0px 1em; text-size-adjust: 100%; vertical-align: baseline;"></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6t2YQ6Qy-FloV0u1Ze3Otk5GsivkyaKUebzFR3_RJnvP6NQxpFCC9Nt-qDTIsdvJ1JdZaj_ZPJbdM7sFCiTC8OLFZKOr9eqhOXCnx0ttbJPFyczvGx0XCMv41HZq8cq_G_o9hsxkYGbM/s634/Full+Join.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="390" data-original-width="634" height="112" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6t2YQ6Qy-FloV0u1Ze3Otk5GsivkyaKUebzFR3_RJnvP6NQxpFCC9Nt-qDTIsdvJ1JdZaj_ZPJbdM7sFCiTC8OLFZKOr9eqhOXCnx0ttbJPFyczvGx0XCMv41HZq8cq_G_o9hsxkYGbM/w181-h112/Full+Join.PNG" width="181" /></a></div><span style="color: #202020; font-family: arial; font-size: 13pt;">The major differences between the two are:</span><p></p><p class="MsoNormal" style="background: white; line-height: normal; margin-left: 36.0pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt; text-indent: -18.0pt;"><!--[if !supportLists]--><span style="font-family: arial;"><span style="color: #202020; font-size: 13pt;">1.<span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;"> </span></span><!--[endif]--><span style="color: #202020; font-size: 13pt;">Data Blending
allows a combination of data from different data sources to be linked. Whereas,
Data Joining works only with data from one and the same source.<br />
For example: If the data is from an Excel sheet and a SQL database, then Data
Blending is the only option to combine the two types of data. However, if the
data is from two Excel sheets, you can use either Data Blending or Data Joining
to combine the data.<o:p></o:p></span></span></p><p class="MsoNormal" style="background: white; line-height: normal; margin-left: 36.0pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 36.0pt; text-indent: -18.0pt;"><!--[if !supportLists]--><span style="font-family: arial;"><span style="color: #202020; font-size: 13pt;">2.<span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;"> </span></span><!--[endif]--><span style="color: #202020; font-size: 13pt;">Data Blending is
also the only choice available when ‘joining’ the tables is impractical. This
impracticality occurs when the data set is humongous. When joins might create
duplicate data or when using databases such as Salesforce and Cubes do not
support Joins.<o:p></o:p></span></span></p><p>
<span style="color: #202020; font-size: 13pt; line-height: 107%;"><span style="font-family: arial;">Tableau considers the first
data source as the primary data source for building the Viz. The other data
sources are for consideration for providing more information. In the Data Area,
a blue check mark denotes the Primary data Source and an Orange check mark
denotes the Secondary data source.</span></span></p>Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com0tag:blogger.com,1999:blog-1347602528429387759.post-802132805325292982019-03-27T00:17:00.001-07:002019-03-27T00:17:54.337-07:00How to create a Calendar table in SQL Server<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Below Query to generate Calendar table based on given Start and End Date:<br />
<br />
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: green; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">---------Code
to generate Calendar table -----------</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">If</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: magenta; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">OBJECT_ID</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">(</span><span style="color: red; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">'tempdb..#Calendar'</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">)</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">IS</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">NOT</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">NULL</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">DROP</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">TABLE</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">
#Calendar<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">Declare</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">
@StartDate </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">date</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">Declare</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">
@EndDate </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">as</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">Date</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><o:p></o:p></span></div>
<br />
<span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">Select</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">
@StartDate </span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">=</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">'2017-03-01'</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><o:p></o:p></span><br />
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">Select</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">
@EndDate</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">=</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;"> </span></span><span style="color: red; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">'2019-04-30'</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"></span> </div>
<div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">CREATE</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">TABLE</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">
#Calendar</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">(</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;"> </span>CalendarMonthStart </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">date</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">PRIMARY</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">KEY</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;"> </span></span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">,</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">
CalendarMonthEnd </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">date</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;"> </span></span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">);</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">WITH</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;"> </span>t4 </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">AS </span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">(</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">SELECT</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> n </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">FROM </span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">(</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">VALUES</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">(</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">0</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">),(</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">0</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">),(</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">0</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">),(</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">0</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">))</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> t</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">(</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">n</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">))</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;"> </span></span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">,</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">t256 </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">AS </span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">(</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">SELECT</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: magenta; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">ROW_NUMBER</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">()</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">OVER </span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">(</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">ORDER</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">BY </span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">(</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">SELECT</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> 0</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">))</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">-</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> 1 </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">AS</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">
num<span style="mso-spacerun: yes;"> </span></span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">FROM</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> t4 </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">AS</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> a </span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">CROSS</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">JOIN</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> t4 </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">AS</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> b </span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">CROSS</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">JOIN</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> t4 </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">AS</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> c </span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">CROSS</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">JOIN</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> t4 </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">AS</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> d</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">)</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">INSERT</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">INTO</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">
#Calendar<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">SELECT</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><o:p></o:p></span></div>
<span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;"> </span></span><span style="color: magenta; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">DATEADD</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">(</span><span style="color: magenta; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">month</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">,</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> num</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">,</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">
@StartDate</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">)</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><o:p></o:p></span><br />
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;"> </span></span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">,</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: magenta; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">DATEADD</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">(</span><span style="color: magenta; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">day</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">,</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">-</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">1</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">,</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: magenta; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">DATEADD</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">(</span><span style="color: magenta; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">month</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">,</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> num </span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">+</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> 1</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">,</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">
@StartDate</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">))</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">FROM</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> t256<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">WHERE</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;"> </span>num </span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><=</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: magenta; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">DATEDIFF</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">(</span><span style="color: magenta; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">month</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">,</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">
@StartDate</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">,</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> @EndDate</span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">);</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"><span style="mso-spacerun: yes;"> </span></span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">Select</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: grey; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">*</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">from</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-font-family: Consolas; mso-bidi-language: HI; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">
#Calendar<o:p></o:p></span></div>
<br />
<br />
Below is output:<br />
<br />
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; width: 249px;">
<colgroup><col style="mso-width-alt: 4551; mso-width-source: userset; width: 96pt;" width="128"></col>
<col style="mso-width-alt: 4295; mso-width-source: userset; width: 91pt;" width="121"></col>
<tbody>
<tr height="19" style="height: 14.4pt;">
<td class="xl68" height="19" style="background-color: #ddebf7; border: 0.5pt solid windowtext; height: 14.4pt; width: 96pt;" width="128"><span style="font-family: Calibri;">CalendarMonthStart</span></td>
<td class="xl68" style="background-color: #ddebf7; border-color: windowtext windowtext windowtext black; border-style: solid solid solid none; border-width: 0.5pt 0.5pt 0.5pt 0px; width: 91pt;" width="121"><span style="font-family: Calibri;">CalendarMonthEnd</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">3/1/2017</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">3/31/2017</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">4/1/2017</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">4/30/2017</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">5/1/2017</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">5/31/2017</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">6/1/2017</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">6/30/2017</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">7/1/2017</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">7/31/2017</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">8/1/2017</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">8/31/2017</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">9/1/2017</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">9/30/2017</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">10/1/2017</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">10/31/2017</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">11/1/2017</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">11/30/2017</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">12/1/2017</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">12/31/2017</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">1/1/2018</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">1/31/2018</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">2/1/2018</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">2/28/2018</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">3/1/2018</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">3/31/2018</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">4/1/2018</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">4/30/2018</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">5/1/2018</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">5/31/2018</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">6/1/2018</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">6/30/2018</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">7/1/2018</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">7/31/2018</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">8/1/2018</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">8/31/2018</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">9/1/2018</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">9/30/2018</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">10/1/2018</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">10/31/2018</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">11/1/2018</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">11/30/2018</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">12/1/2018</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">12/31/2018</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">1/1/2019</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">1/31/2019</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">2/1/2019</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">2/28/2019</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">3/1/2019</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">3/31/2019</span></td>
</tr>
<tr height="19" style="height: 14.4pt;">
<td align="right" class="xl67" height="19" style="background-color: transparent; border-color: black windowtext windowtext; border-style: none solid solid; border-width: 0px 0.5pt 0.5pt; height: 14.4pt;"><span style="font-family: Calibri;">4/1/2019</span></td>
<td align="right" class="xl67" style="background-color: transparent; border-color: black windowtext windowtext black; border-style: none solid solid none; border-width: 0px 0.5pt 0.5pt 0px;"><span style="font-family: Calibri;">4/30/2019</span></td>
</tr>
</tbody></colgroup></table>
</div>
Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com0tag:blogger.com,1999:blog-1347602528429387759.post-58382434093251132222019-03-27T00:01:00.000-07:002019-03-27T00:01:55.927-07:00Get Week End Date Using SQL Server<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: black;">Below SQL code will provide End Date of a week:</span><br />
<span style="color: black;"></span><br />
<span style="color: black;">Here in below SQL code, I have used <strong>SET DATEFIRST 1</strong> because 1 is for Start of my week is from Monday so If you want to start your week from another day of week than you can replace 1 with that particular Day number so based on your start week day, end day of week will get calculated.</span><br />
<span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"></span></span></span><br />
<span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"></span></span></span><br />
<span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">SET</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> </span></span><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">DATEFIRST</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> 1 </span></span><br />
<br /></span> </span> </span><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">Declare</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> @UpdateDate </span></span><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">Date</span></span></span><br />
<br />
<span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">
</span></span></span><br />
<span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">Set</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> @UpdateDate</span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">=</span></span></span><span style="color: magenta; font-family: Consolas; font-size: x-small;"><span style="color: magenta; font-family: Consolas; font-size: x-small;"><span style="color: magenta; font-family: Consolas; font-size: x-small;">GetDate</span></span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">()</span></span></span><br />
<span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">
</span></span></span><br />
<span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">
</span><span style="font-family: Consolas; font-size: x-small;"> </span><br />
<span style="font-family: Consolas; font-size: x-small;">
<span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">Select</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> </span></span></span><br />
<br /></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">
</span></span><br />
<span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> </span></span><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">Case</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> </span></span><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">When</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> </span></span><span style="color: magenta; font-family: Consolas; font-size: x-small;"><span style="color: magenta; font-family: Consolas; font-size: x-small;"><span style="color: magenta; font-family: Consolas; font-size: x-small;">DATEPART</span></span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">(</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">dw</span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">,</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">@UpdateDate</span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">)</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> </span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">=</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">7 </span></span><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">then</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> @UpdateDate</span></span><br />
<span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"></span></span><br />
<span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">Else</span></span></span></span></span></span></span><br />
<span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">
</span></span></span></span></span></span></span><span style="color: magenta; font-family: Consolas; font-size: x-small;"><span style="color: magenta; font-family: Consolas; font-size: x-small;"><span style="color: magenta; font-family: Consolas; font-size: x-small;"></span></span></span><span style="color: magenta; font-family: Consolas; font-size: x-small;"><span style="color: magenta; font-family: Consolas; font-size: x-small;"><span style="color: magenta; font-family: Consolas; font-size: x-small;">Dateadd</span></span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">(</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">dd</span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">,(</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">7</span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">-</span></span></span><span style="color: magenta; font-family: Consolas; font-size: x-small;"><span style="color: magenta; font-family: Consolas; font-size: x-small;"><span style="color: magenta; font-family: Consolas; font-size: x-small;">DATEPART</span></span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">(</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">dw</span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">,</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">@UpdateDate</span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">)),</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">@UpdateDate</span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">)</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> </span></span><br />
<span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">
</span></span><br />
<span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> </span></span><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">end</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> </span></span><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">as</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> WeekEndDate</span></span></div>
Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com0tag:blogger.com,1999:blog-1347602528429387759.post-10161914807452353772019-03-26T23:34:00.000-07:002019-03-26T23:34:27.760-07:00Get Week Start Date in SQL Server with example<div dir="ltr" style="text-align: left;" trbidi="on">
Below SQL code will provide Start Date of a week:<br />
<br />
Here in below SQL code, I have used <strong>SET DATEFIRST 1</strong> because 1 is for Start of my week is from Monday so If you want to start your week from another day of week than you can replace 1 with that particular Day number.<br />
<br />
<br />
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">SET</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> </span></span><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">DATEFIRST</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> 1 </span></span><br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">
</span></span><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"></span></span></span></div>
<span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">Declare</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> @UpdateDate </span></span><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">Date</span></span></span><br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">
</span></span></span></div>
<span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">Set</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> @UpdateDate</span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">=</span></span></span><span style="color: red; font-family: Consolas; font-size: x-small;"><span style="color: red; font-family: Consolas; font-size: x-small;"><span style="color: red; font-family: Consolas; font-size: x-small;">'03/12/2019'</span></span></span><br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="color: red; font-family: Consolas; font-size: x-small;"><span style="color: red; font-family: Consolas; font-size: x-small;"><span style="color: red; font-family: Consolas; font-size: x-small;">
</span></span></span></div>
<span style="font-family: Consolas; font-size: x-small;"><div class="MsoNormal" style="margin: 0in 0in 0pt;">
</div>
<span style="font-family: Consolas; font-size: x-small;"><div class="MsoNormal" style="margin: 0in 0in 0pt;">
</div>
</span></span><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"></span></span></span><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">Select</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> </span></span><br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">
</span></span></div>
<span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> </span></span><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">Case</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> </span></span><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">When</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> </span></span><span style="color: magenta; font-family: Consolas; font-size: x-small;"><span style="color: magenta; font-family: Consolas; font-size: x-small;"><span style="color: magenta; font-family: Consolas; font-size: x-small;">DATEPART</span></span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">(</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">dw</span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">,</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">@UpdateDate</span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">)</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> </span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">=</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">1 </span></span><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">then</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> @UpdateDate</span></span><br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">
<span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"></span></span></span></span><div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"></span></span></span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">Else</span></span></span></span></span><br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">
<span style="color: magenta; font-family: Consolas; font-size: x-small;"><span style="color: magenta; font-family: Consolas; font-size: x-small;"><span style="color: magenta; font-family: Consolas; font-size: x-small;">Dateadd</span></span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">(</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">dd</span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">,-(</span></span></span><span style="color: magenta; font-family: Consolas; font-size: x-small;"><span style="color: magenta; font-family: Consolas; font-size: x-small;"><span style="color: magenta; font-family: Consolas; font-size: x-small;">DATEPART</span></span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">(</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">dw</span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">,</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">@UpdateDate</span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">)-</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">1</span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">),</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">@UpdateDate</span></span><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;"><span style="color: grey; font-family: Consolas; font-size: x-small;">)</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> </span></span></span></span></span></span></span></div>
<br />
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">
</span></span></div>
<span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> </span></span><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">end</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> </span></span><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: x-small;">as</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> WeekStartDate</span></span></div>
</div>
</span><div class="MsoNormal" style="margin: 0in 0in 0pt;">
</div>
</div>
Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com0tag:blogger.com,1999:blog-1347602528429387759.post-7011139273138102272018-09-17T07:32:00.001-07:002018-09-17T07:32:56.210-07:00Select query order of execution in SQL Server<div dir="ltr" style="text-align: left;" trbidi="on">
In Many interview, this questions generally asked by the interviewer that what is the correct order of Select query for execution by SQL Server engine.<br />
<br />
Below I have mentioned the correct order of SQL server query execution which SQL Server used to execute:<br />
<br />
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #333333; font-family: "Segoe UI",sans-serif; font-size: 10.5pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">1. FROM and Joins<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #333333; font-family: "Segoe UI",sans-serif; font-size: 10.5pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">2. Where<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #333333; font-family: "Segoe UI",sans-serif; font-size: 10.5pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">3. Group By<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #333333; font-family: "Segoe UI",sans-serif; font-size: 10.5pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">4. Having<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #333333; font-family: "Segoe UI",sans-serif; font-size: 10.5pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">5. Select<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #333333; font-family: "Segoe UI",sans-serif; font-size: 10.5pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">6. Distinct<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #333333; font-family: "Segoe UI",sans-serif; font-size: 10.5pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">7. Top<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm;">
<span style="color: #333333; font-family: "Segoe UI",sans-serif; font-size: 10.5pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">7. Order By <o:p></o:p></span></div>
<br /></div>
Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com0tag:blogger.com,1999:blog-1347602528429387759.post-64208204286888753642018-09-17T07:28:00.000-07:002018-09-17T07:28:04.598-07:00SQL Server Functions with examples<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><u><span style="background: white; color: #252525; font-family: "Segoe UI",sans-serif; font-size: 10.5pt; line-height: 115%;">SQL Server Functions :<o:p></o:p></span></u></b></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><u><span style="background: white; color: #252525; font-family: "Segoe UI",sans-serif; font-size: 10.5pt; line-height: 115%;"><br /></span></u></b></div>
<div class="MsoNormal">
<span style="background: #FCFCFC; color: #161616; font-family: "Segoe UI",sans-serif;">Functions in SQL Server is a set of SQL statements that
accepts only input parameters at run time and perform some actions and return the
result, which can be only single value or a table.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: #FCFCFC; color: #161616; font-family: "Segoe UI",sans-serif;"><br /></span></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><u><span style="background: white; color: #252525; font-family: "Segoe UI",sans-serif; font-size: 10.5pt; line-height: 115%;">Types of Functions:<o:p></o:p></span></u></b></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><u><span style="background: white; color: #252525; font-family: "Segoe UI",sans-serif; font-size: 10.5pt; line-height: 115%;"><br /></span></u></b></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><u>System Defined
Function</u></b>: </div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
These functions are defined by SQL Server so these are Pre-defined functions. Like:<span style="mso-spacerun: yes;"> </span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
AVG()</div>
<div class="MsoNormal">
COUNT()</div>
<div class="MsoNormal">
Sum()</div>
<div class="MsoNormal">
ABS() </div>
<div class="MsoNormal">
Round() </div>
<div class="MsoNormal">
Convert() <o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
To use system defined function we have to pass parameters
information only to get output from these functions.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><u>User Defined
Functions</u></b>: </div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
These Functions are created by Users in database for
performing some operations on data.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Types of User Defined Functions are:<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><u>Scalar Function:</u><o:p></o:p></b></div>
<div class="MsoNormal">
<span style="background: #FCFCFC; color: #161616; font-family: "Segoe UI",sans-serif;">User defined scalar function also returns single value as a
result of actions perform by function. We return any datatype value from
function.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: #FCFCFC; color: #161616; font-family: "Segoe UI",sans-serif;"><br /></span></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><u><span style="background: #FCFCFC; color: #161616; font-family: "Segoe UI",sans-serif;">Example:<o:p></o:p></span></u></b></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><u><span style="background: #FCFCFC; color: #161616; font-family: "Segoe UI",sans-serif;"><br /></span></u></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">--Create
function to get employee full name </span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><br /></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Create</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">function</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> <span style="font-size: 12.6667px;">UFD_GetEmp</span>FullName<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span>@FirstName </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">varchar</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">50</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">),</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span>@LastName </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">varchar</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">50</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">returns</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">varchar</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">101</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">As</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Begin</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">return </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Select</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> @FirstName </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">+</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">' '</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">+</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> @LastName</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">);</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">end</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">--Calling
the above created function</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><br /></span></div>
<div class="MsoNormal">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">Select</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> dbo</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">.</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"><span style="color: black; font-size: 12.6667px;">UFD_GetEmp</span><span style="color: black; font-size: 12.6667px;">FullName</span>(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">FirstName</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">LastName</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">as</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> Name</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> Salary </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">from</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> dbo.Employee</span><span style="background: #FCFCFC; color: #161616; font-family: "Segoe UI",sans-serif;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><u>Inline Table-Valued
Function:</u><o:p></o:p></b></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><br /></b></div>
<div class="MsoNormal">
<span style="background: #FCFCFC; color: #161616; font-family: "Segoe UI",sans-serif;">User defined inline table-valued function returns a table
variable as a result of actions perform by function. The value of table
variable should be derived from a single SELECT statement.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: #FCFCFC; color: #161616; font-family: "Segoe UI",sans-serif;"><br /></span></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><u><span style="background: #FCFCFC; color: #161616; font-family: "Segoe UI",sans-serif;">Example:<o:p></o:p></span></u></b></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><u><span style="background: #FCFCFC; color: #161616; font-family: "Segoe UI",sans-serif;"><br /></span></u></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">--Create
function to get employees</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><br /></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Create</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">function</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> UFD_GetEmpDetails</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">()</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">returns</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Table</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">As</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">return </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Select</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">*</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">from</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> dbo.Employee</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">--Call the above created function</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><br /></span></div>
<div class="MsoNormal">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">Select</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">*</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">from</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"><span style="color: black; font-size: 12.6667px;">UFD_GetEmpDetails</span>()</span><o:p></o:p></div>
<div class="MsoNormal">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"><br /></span></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><u>Multi-Statement
Table-Value Function:</u><o:p></o:p></b></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><br /></b></div>
<div class="MsoNormal">
<span style="background: #FCFCFC; color: #161616; font-family: "Segoe UI",sans-serif;">User defined multi-statement table-valued function returns
a table variable as a result of actions perform by function. In this a table
variable must be explicitly declared and defined whose value can be derived
from a multiple SQL statements.</span><o:p></o:p></div>
<div class="MsoNormal">
<span style="background: #FCFCFC; color: #161616; font-family: "Segoe UI",sans-serif;"><br /></span></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><u>Example:<o:p></o:p></u></b></div>
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;"><u><br /></u></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">--Create
function for EmpID,FirstName and Salary of Employee</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><br /></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Create</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">function</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> UFD_GetMulEmployee</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">()</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">returns</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> @Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Table</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">EmpID
</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">int</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">FirstName
</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">varchar</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">50</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">),</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Salary
</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">int</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">As</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">begin</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> <span style="font-size: 12.6667px;">@Employee</span> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Select</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> e</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">EmpID</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">e</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">FirstName</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">e</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Salary </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">from</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> dbo.Employee e</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">;</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><br /></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">--Now
update salary of first employee</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><br /></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">update</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> <span style="font-size: 12.6667px;">@Employee</span> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">set</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Salary</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">25000 </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">where</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> EmpID</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">1</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">;</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><br /></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">--It
will update only in @Emp table not in Original Employee table</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><br /></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">return</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">end</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><br /></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">--Call the above created function</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: green; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><br /></span></div>
<div class="MsoNormal">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">Select</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">*</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">from</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background-color: white; font-family: Consolas; font-size: 12.6667px;">UFD_</span><span style="background: white; font-family: Consolas; font-size: 9.5pt; line-height: 115%;">GetMulEmployee</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%;">()</span></div>
<br /></div>
Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com0tag:blogger.com,1999:blog-1347602528429387759.post-83220438646890035322018-09-17T07:15:00.003-07:002018-09-17T07:15:51.607-07:00SQL Server maximum number of indexes per table<div dir="ltr" style="text-align: left;" trbidi="on">
In SQL server, maximum number of indexes are as:<br />
<br />
<u>In SQL server 2005 number of indexes per table as:</u><br />
<br />
Clustered Index - 1<br />
<br />
Non Clustered Index - 249<br />
<br />
Total Indexes per table (Clustered + Non-Clustered) - 250<br />
<br />
<u>In SQL Server 2008 and 2012 number of indexes per table as:</u><br />
<br />
Clustered Index - 1<br />
<br />
Non Clustered Index - 999<br />
<br />
Total Indexes per table (Clustered + Non-Clustered) - 1000<br />
<br />
<b style="text-decoration-line: underline;">Note:</b> You can put as many indexes per table but keep in mind, insert or update operation on that table will be slow due to many indexes.<br />
<br />
To Learn more about SQL Server capacity, please go through Microsoft page:<br />
<a href="https://docs.microsoft.com/en-us/sql/sql-server/maximum-capacity-specifications-for-sql-server?view=sql-server-2017">https://docs.microsoft.com/en-us/sql/sql-server/maximum-capacity-specifications-for-sql-server?view=sql-server-2017</a><br />
<br />
<br /></div>
Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com0tag:blogger.com,1999:blog-1347602528429387759.post-43151483764249801062018-08-03T04:43:00.000-07:002018-08-03T04:43:06.562-07:00Export Data to multiple excel sheet from SQL server Table using SSIS<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="background: white; line-height: 27.5pt; margin-bottom: .0001pt; margin-bottom: 0cm; mso-outline-level: 1;">
<b style="mso-bidi-font-weight: normal;"><u><span style="border: none windowtext 1.0pt; color: #3a3e43; font-family: "inherit","serif"; font-size: 12.0pt; mso-bidi-font-family: "Segoe UI"; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt; padding: 0cm;">Export Data to
multiple excel sheet from SQL server Table using SSIS<o:p></o:p></span></u></b></div>
<div class="MsoNormal" style="background: white; line-height: 27.5pt; margin-bottom: .0001pt; margin-bottom: 0cm; mso-outline-level: 1;">
<span style="border: none windowtext 1.0pt; color: #3a3e43; font-family: "inherit","serif"; mso-bidi-font-family: "Segoe UI"; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt; padding: 0cm;">Below solution
where we need to export SQL data into multiple excel sheets, as we have below
data in our SQL Table:<o:p></o:p></span></div>
<div style="background: white; margin-bottom: .0001pt; margin: 0cm;">
<br /></div>
<div style="background: white; margin-bottom: .0001pt; margin: 0cm;">
<span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">LoanID</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: none windowtext 1.0pt; color: #333333; font-family: "inherit","serif"; font-size: 10.5pt; mso-bidi-font-family: "Segoe UI"; mso-border-alt: none windowtext 0cm; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">State</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: none windowtext 1.0pt; color: #333333; font-family: "inherit","serif"; font-size: 10.5pt; mso-bidi-font-family: "Segoe UI"; mso-border-alt: none windowtext 0cm; padding: 0cm;"> </span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"> </span></span><span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">TYPE</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: none windowtext 1.0pt; color: #333333; font-family: "inherit","serif"; font-size: 10.5pt; mso-bidi-font-family: "Segoe UI"; mso-border-alt: none windowtext 0cm; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">STEP<o:p></o:p></span></div>
<div style="-webkit-text-stroke-width: 0px; background: white; font-variant-caps: normal; font-variant-ligatures: normal; margin-bottom: .0001pt; margin: 0cm; orphans: 2; outline: 0px; widows: 2; word-spacing: 0px;">
<span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">2</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: none windowtext 1.0pt; color: #333333; font-family: "inherit","serif"; font-size: 10.5pt; mso-bidi-font-family: "Segoe UI"; mso-border-alt: none windowtext 0cm; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">CA</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: none windowtext 1.0pt; color: #333333; font-family: "inherit","serif"; font-size: 10.5pt; mso-bidi-font-family: "Segoe UI"; mso-border-alt: none windowtext 0cm; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">R6</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: none windowtext 1.0pt; color: #333333; font-family: "inherit","serif"; font-size: 10.5pt; mso-bidi-font-family: "Segoe UI"; mso-border-alt: none windowtext 0cm; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">1<o:p></o:p></span></div>
<div style="-webkit-text-stroke-width: 0px; background: white; font-variant-caps: normal; font-variant-ligatures: normal; margin-bottom: .0001pt; margin: 0cm; orphans: 2; outline: 0px; widows: 2; word-spacing: 0px;">
<span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">3</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: none windowtext 1.0pt; color: #333333; font-family: "inherit","serif"; font-size: 10.5pt; mso-bidi-font-family: "Segoe UI"; mso-border-alt: none windowtext 0cm; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">CA</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: none windowtext 1.0pt; color: #333333; font-family: "inherit","serif"; font-size: 10.5pt; mso-bidi-font-family: "Segoe UI"; mso-border-alt: none windowtext 0cm; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">R6</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: none windowtext 1.0pt; color: #333333; font-family: "inherit","serif"; font-size: 10.5pt; mso-bidi-font-family: "Segoe UI"; mso-border-alt: none windowtext 0cm; padding: 0cm;"> </span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"> </span></span><span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">3<o:p></o:p></span></div>
<div style="-webkit-text-stroke-width: 0px; background: white; font-variant-caps: normal; font-variant-ligatures: normal; margin-bottom: .0001pt; margin: 0cm; orphans: 2; outline: 0px; widows: 2; word-spacing: 0px;">
<span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">4</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: none windowtext 1.0pt; color: #333333; font-family: "inherit","serif"; font-size: 10.5pt; mso-bidi-font-family: "Segoe UI"; mso-border-alt: none windowtext 0cm; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">CA</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: none windowtext 1.0pt; color: #333333; font-family: "inherit","serif"; font-size: 10.5pt; mso-bidi-font-family: "Segoe UI"; mso-border-alt: none windowtext 0cm; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">P1</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: none windowtext 1.0pt; color: #333333; font-family: "inherit","serif"; font-size: 10.5pt; mso-bidi-font-family: "Segoe UI"; mso-border-alt: none windowtext 0cm; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">4<o:p></o:p></span></div>
<div style="-webkit-text-stroke-width: 0px; background: white; font-variant-caps: normal; font-variant-ligatures: normal; margin-bottom: .0001pt; margin: 0cm; orphans: 2; outline: 0px; widows: 2; word-spacing: 0px;">
<span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">67</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: none windowtext 1.0pt; color: #333333; font-family: "inherit","serif"; font-size: 10.5pt; mso-bidi-font-family: "Segoe UI"; mso-border-alt: none windowtext 0cm; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">CA</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: none windowtext 1.0pt; color: #333333; font-family: "inherit","serif"; font-size: 10.5pt; mso-bidi-font-family: "Segoe UI"; mso-border-alt: none windowtext 0cm; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">P1 </span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: none windowtext 1.0pt; color: #333333; font-family: "inherit","serif"; font-size: 10.5pt; mso-bidi-font-family: "Segoe UI"; mso-border-alt: none windowtext 0cm; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">5<o:p></o:p></span></div>
<div style="-webkit-text-stroke-width: 0px; background: white; font-variant-caps: normal; font-variant-ligatures: normal; margin-bottom: .0001pt; margin: 0cm; orphans: 2; outline: 0px; widows: 2; word-spacing: 0px;">
<span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">45</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: none windowtext 1.0pt; color: #333333; font-family: "inherit","serif"; font-size: 10.5pt; mso-bidi-font-family: "Segoe UI"; mso-border-alt: none windowtext 0cm; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">CA</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: none windowtext 1.0pt; color: #333333; font-family: "inherit","serif"; font-size: 10.5pt; mso-bidi-font-family: "Segoe UI"; mso-border-alt: none windowtext 0cm; padding: 0cm;"> </span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"> </span></span><span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">R2 </span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: none windowtext 1.0pt; color: #333333; font-family: "inherit","serif"; font-size: 10.5pt; mso-bidi-font-family: "Segoe UI"; mso-border-alt: none windowtext 0cm; padding: 0cm;"> </span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"> </span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"> </span></span><span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">7<o:p></o:p></span></div>
<div style="-webkit-text-stroke-width: 0px; background: white; font-variant-caps: normal; font-variant-ligatures: normal; margin-bottom: .0001pt; margin: 0cm; orphans: 2; outline: 0px; widows: 2; word-spacing: 0px;">
<span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">23</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: none windowtext 1.0pt; color: #333333; font-family: "inherit","serif"; font-size: 10.5pt; mso-bidi-font-family: "Segoe UI"; mso-border-alt: none windowtext 0cm; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">CA</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: none windowtext 1.0pt; color: #333333; font-family: "inherit","serif"; font-size: 10.5pt; mso-bidi-font-family: "Segoe UI"; mso-border-alt: none windowtext 0cm; padding: 0cm;"> </span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"> </span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"> </span></span><span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">R2</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: none windowtext 1.0pt; color: #333333; font-family: "inherit","serif"; font-size: 10.5pt; mso-bidi-font-family: "Segoe UI"; mso-border-alt: none windowtext 0cm; padding: 0cm;"> </span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"> </span></span><span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">8<o:p></o:p></span></div>
<div style="background: white; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;">
<span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">Now we want excel file (Destination) to have multiple tabs using
column 'State' and 'Type'.<o:p></o:p></span></div>
<div style="-webkit-text-stroke-width: 0px; background: white; font-variant-caps: normal; font-variant-ligatures: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm; orphans: 2; outline: 0px; widows: 2; word-spacing: 0px;">
<span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">Below
is how result in excel should be:<o:p></o:p></span></div>
<div style="background: white; margin: 0cm 0cm 0.0001pt; outline: 0px;">
<span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">LoanID</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">State</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">TYPE</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">STEP<o:p></o:p></span></div>
<div style="background: white; margin: 0cm 0cm 0.0001pt; outline: 0px;">
<span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">2</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">CA</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">R6</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">1<o:p></o:p></span></div>
<div style="background: white; margin: 0cm 0cm 0.0001pt; outline: 0px;">
<span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">3</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">CA</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">R6</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">3<o:p></o:p></span></div>
<div style="background: white; margin: 0cm 0cm 12pt; outline: 0px;">
<br /></div>
<div style="background: white; margin: 0cm 0cm 12pt;">
<span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">Second tab should be 'CA-P1'<o:p></o:p></span></div>
<div style="background: white; margin: 0cm 0cm 0.0001pt; outline: 0px;">
<span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">LoanID</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">State</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">TYPE</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">STEP<o:p></o:p></span></div>
<div style="background: white; margin: 0cm 0cm 0.0001pt; outline: 0px;">
<span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">4</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">CA</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">P1</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">4<o:p></o:p></span></div>
<div style="background: white; margin: 0cm 0cm 0.0001pt; outline: 0px;">
<span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">67</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">CA</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">P1 </span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">5<o:p></o:p></span></div>
<div style="background: white; margin: 0cm 0cm 12pt; outline: 0px;">
<br /></div>
<div style="background: white; margin: 0cm 0cm 12pt; outline: 0px;">
<span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">And Third tab will be 'CA-R2'<o:p></o:p></span></div>
<div style="background: white; margin: 0cm 0cm 0.0001pt; outline: 0px;">
<span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">LoanID</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">State</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">TYPE</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">STEP<o:p></o:p></span></div>
<div style="background: white; margin: 0cm 0cm 0.0001pt; outline: 0px;">
<span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">45</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">CA</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">R2 </span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"> </span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">7<o:p></o:p></span></div>
<div style="background: white; margin: 0cm 0cm 0.0001pt; outline: 0px;">
<span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">23</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">CA</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"> </span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">R2</span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: #333333; font-family: inherit, serif; font-size: 10.5pt; padding: 0cm;"> </span><span style="font-style: inherit; font-weight: inherit; outline: 0px;"> </span></span><span style="color: #333333; font-family: "Segoe UI", sans-serif; font-size: 10.5pt;">8<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 27.5pt; margin-bottom: 0.0001pt;">
<span style="border: 1pt none windowtext; color: #3a3e43; font-family: inherit, serif; padding: 0cm;">Solution:</span></div>
<div style="-webkit-text-stroke-width: 0px; background: white; font-variant-caps: normal; font-variant-ligatures: normal; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm; orphans: 2; outline: 0px; widows: 2; word-spacing: 0px;">
<span style="color: #333333; font-family: "Segoe UI","sans-serif"; font-size: 10.5pt;">First
tab should be 'CA-R6'</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgObUNqwXkEFIlwj29fbum0rx-NS9wNGL7QRzCWkO92Oclr1O00h9UoDWxw-_R4xx9VIV1zIOiRFU0_x9h3bfgtADiAp1tqNl2niZjKcKq1YQJ7eFrIRrvf-eEUMq5j-I3N0PHEvzp40Po/s1600/Img1.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="905" data-original-width="739" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgObUNqwXkEFIlwj29fbum0rx-NS9wNGL7QRzCWkO92Oclr1O00h9UoDWxw-_R4xx9VIV1zIOiRFU0_x9h3bfgtADiAp1tqNl2niZjKcKq1YQJ7eFrIRrvf-eEUMq5j-I3N0PHEvzp40Po/s1600/Img1.JPG" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmD5MkI9-oL21ZRLVgyZIWKPShpxbLrYfvoToOI5lOAq6NisOyf6t86IYgcTXd8D5HSZQKTiQR47OlD_R8_elTWHYfwhgmyzHsfFIsQstEWJHl1acxPajc3wZlGAls_-drzkI9Zll8w1Y/s1600/Img2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="635" data-original-width="835" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmD5MkI9-oL21ZRLVgyZIWKPShpxbLrYfvoToOI5lOAq6NisOyf6t86IYgcTXd8D5HSZQKTiQR47OlD_R8_elTWHYfwhgmyzHsfFIsQstEWJHl1acxPajc3wZlGAls_-drzkI9Zll8w1Y/s1600/Img2.JPG" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjY7lsskGvzp1Az-kG_F_6sxHViipy3hKEi3ysbdeQLGXUYwKUY_7vRWBZqWL6BO7HowZRf37Y_KmX1pxs4RdtkqiO1RMF8HZ_pp1h5raMqQ2SHSvRVfrSG9uFmAlGuhmeH-TNF0t46q9w/s1600/Img3.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1043" data-original-width="817" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjY7lsskGvzp1Az-kG_F_6sxHViipy3hKEi3ysbdeQLGXUYwKUY_7vRWBZqWL6BO7HowZRf37Y_KmX1pxs4RdtkqiO1RMF8HZ_pp1h5raMqQ2SHSvRVfrSG9uFmAlGuhmeH-TNF0t46q9w/s1600/Img3.JPG" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjL5V453ujBJpDzJ1IayI31_qUONrzOhERj-dncfEiuFWUGTFMTin9XSUO3a8HyONHUGWgHU0ECvWq6Orv2d1b9ZjSs4BTdong_RagllCUoIeB7MYo-wFDxeFudJj95dSO1NVbg3O-_ikA/s1600/Img4.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="952" data-original-width="819" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjL5V453ujBJpDzJ1IayI31_qUONrzOhERj-dncfEiuFWUGTFMTin9XSUO3a8HyONHUGWgHU0ECvWq6Orv2d1b9ZjSs4BTdong_RagllCUoIeB7MYo-wFDxeFudJj95dSO1NVbg3O-_ikA/s1600/Img4.JPG" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKPTX8VKLjDZApHfBjYsGsV9eFzGdBvRjo4snGG1UnF_wHgJybgW2dnnFwvjzaNjku3vIPW2o1jRk_3A_91gdDVJFqoJsGV9aXVkkgS62PVU4gqpVyTCnmlHe-iLjACwI_3F_6TnrQero/s1600/Img5.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="628" data-original-width="791" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKPTX8VKLjDZApHfBjYsGsV9eFzGdBvRjo4snGG1UnF_wHgJybgW2dnnFwvjzaNjku3vIPW2o1jRk_3A_91gdDVJFqoJsGV9aXVkkgS62PVU4gqpVyTCnmlHe-iLjACwI_3F_6TnrQero/s1600/Img5.JPG" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<o:p></o:p><br />
<div style="-webkit-text-stroke-width: 0px; background: white; font-variant-caps: normal; font-variant-ligatures: normal; margin-bottom: .0001pt; margin: 0cm; orphans: 2; outline: 0px; widows: 2; word-spacing: 0px;">
<br /></div>
<br /></div>
Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com0tag:blogger.com,1999:blog-1347602528429387759.post-48572568117623515422018-08-03T01:57:00.002-07:002018-08-03T01:57:56.220-07:00Sorting Alpha Numeric and Numeric data in SQL Server<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="background: white; line-height: 27.5pt; margin-bottom: .0001pt; margin-bottom: 0cm; mso-outline-level: 1;">
<b><u>Sorting Alpha Numeric and Numeric data<o:p></o:p></u></b></div>
<div style="background: white; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;">
<br /></div>
<div style="background: white; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;">
<span style="font-family: "Calibri","sans-serif"; font-size: 11.0pt; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">I have a varchar2
column in which data is present like :<o:p></o:p></span></div>
<div style="background: white; margin: 0cm 0cm 12pt; outline: 0px;">
<span style="font-family: "Calibri","sans-serif"; font-size: 11.0pt; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">1a<o:p></o:p></span></div>
<div style="background: white; margin: 0cm 0cm 12pt; outline: 0px;">
<span style="font-family: "Calibri","sans-serif"; font-size: 11.0pt; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">1b<o:p></o:p></span></div>
<div style="background: white; margin: 0cm 0cm 12pt; outline: 0px;">
<span style="font-family: "Calibri","sans-serif"; font-size: 11.0pt; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">1c<o:p></o:p></span></div>
<div style="background: white; margin: 0cm 0cm 12pt; outline: 0px;">
<span style="font-family: "Calibri","sans-serif"; font-size: 11.0pt; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">1<o:p></o:p></span></div>
<div style="background: white; margin: 0cm 0cm 12pt; outline: 0px;">
<span style="font-family: "Calibri","sans-serif"; font-size: 11.0pt; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">2<o:p></o:p></span></div>
<div style="background: white; margin: 0cm 0cm 12pt; outline: 0px;">
<span style="font-family: "Calibri","sans-serif"; font-size: 11.0pt; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">2a<o:p></o:p></span></div>
<div style="background: white; margin: 0cm 0cm 12pt; outline: 0px;">
<span style="font-family: "Calibri","sans-serif"; font-size: 11.0pt; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">2d <o:p></o:p></span></div>
<div style="background: white; margin: 0cm 0cm 12pt; outline: 0px;">
<span style="font-family: "Calibri","sans-serif"; font-size: 11.0pt; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">and so on ... and
output should be sorted like :<o:p></o:p></span></div>
<div style="background: white; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 0cm;">
<span style="font-family: "Calibri","sans-serif"; font-size: 11.0pt; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">1,1a,1b,2,2c,2d
........ 11,22,23,24d ...<o:p></o:p></span></div>
<div class="MsoNormal">
Below Query where I have used PATINDEX function of SQL
Server, which <span style="background: white; color: #212121; font-family: "Segoe UI","sans-serif";">is similar to the like operator</span><o:p></o:p></div>
<div style="background: white; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt;">
<b><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #212121; font-family: "Segoe UI", sans-serif;">Syntax : </span></b><span style="color: #212121; font-family: "Segoe UI","sans-serif"; font-size: 10.0pt;">The Patindex function
takes two arguments:</span><span style="color: #212121; font-family: "Open Sans","sans-serif"; font-size: 10.5pt;"><o:p></o:p></span></div>
<div style="background: white; box-sizing: border-box; margin: 12pt 0cm;">
<span style="color: #212121; font-family: "Segoe UI","sans-serif"; font-size: 10.0pt;">PATINDEX ('%pattern%', exp)<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">declare</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"> @t </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">table</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; font-family: Consolas; font-size: 9.5pt;">v </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">varchar</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;">20</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">insert</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"> @t<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">values
</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'1a'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">),</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'1b'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">),</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'1c'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">),</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'1'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">),</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'2'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">),</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'2a'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">),</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'2d '</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">),</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'11c '</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">),</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'111d '</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">),</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'11 '</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">),</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'22 '</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">),</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'222a '</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">),</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'222 '</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">),</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'111 '</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">),</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'11 '</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">select</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">*</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">from</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"> @t<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">order</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">by</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">left(</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;">v</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">patindex</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'%[^0-9]%'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;">v </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">+</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'x'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)-</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;">1</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">*</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;"> 1</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; font-family: Consolas; font-size: 9.5pt;">v<o:p></o:p></span></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
</div>
Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com0tag:blogger.com,1999:blog-1347602528429387759.post-71080287853523576122018-05-30T05:49:00.000-07:002018-05-30T05:49:31.958-07:00Exclude 0 from value in SQL Server<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<b style="mso-bidi-font-weight: normal;"><u><span style="color: black; font-family: Consolas; font-size: 9.5pt;">Exclude
0 from value in SQL Server<o:p></o:p></span></u></b></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Create</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Table</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #TempData<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">ColumnData
</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Varchar</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">20</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #TempData </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">values</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'063506038'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #TempData </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">values</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'0063506038'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #TempData </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">values</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'00063506038'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #TempData </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">values</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'00000063506038'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Select</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">*</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">from</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #TempData<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">Select</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">REPLACE</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">(</span><span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">LTRIM</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">(</span><span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">REPLACE</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> ColumnData</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">'0'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">' '</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">)),</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">' '</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">'0'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">From</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> #TempData</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;"><o:p></o:p></span></div>
</div>
Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com0tag:blogger.com,1999:blog-1347602528429387759.post-71806313284748655072018-05-30T05:12:00.002-07:002018-05-30T05:12:30.370-07:00Format Date in SSIS MM-DD-YYYY or MM/DD/YYYY DD-MM-YYYY or DD/MM/YYYY<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">Format Date in SSIS MM-DD-YYYY or MM/DD/YYYY DD-MM-YYYY or
DD/MM/YYYY<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<b style="mso-bidi-font-weight: normal;"><u><span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;">Date
Format MM-DD-YYYY:<o:p></o:p></span></u></b></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;">RIGHT("0" + (DT_STR,4,1252)DATEPART(
"dd" , getdate() ), 2) <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;">+"-"+RIGHT("0" +
(DT_STR,4,1252)DATEPART( "mm" , getdate() ), 2) +"-"+<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;">(DT_STR,4,1252)DATEPART( "yyyy" , getdate() )<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;"><b style="mso-bidi-font-weight: normal;"><u><span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;">Date
Format MM/DD/YYYY:<o:p></o:p></span></u></b></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;">RIGHT("0" + (DT_STR,4,1252)DATEPART(
"dd" , getdate() ), 2) <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;">+"/"+RIGHT("0" + (DT_STR,4,1252)DATEPART(
"mm" , getdate() ), 2) +"/"+<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;">(DT_STR,4,1252)DATEPART( "yyyy" , getdate() )<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<b style="mso-bidi-font-weight: normal;"><u><span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;">Date
Format DD-MM-YYYY:<o:p></o:p></span></u></b></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;">RIGHT("0" + (DT_STR,4,1252)DATEPART(
"mm" , getdate() ), 2) +"-"+<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;">RIGHT("0" + (DT_STR,4,1252)DATEPART(
"dd" , getdate() ), 2) <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;">+"-"+(DT_STR,4,1252)DATEPART( "yyyy"
, getdate() )<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<b style="mso-bidi-font-weight: normal;"><u><span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;">Date
Format DD/MM/YYYY:<o:p></o:p></span></u></b></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;">RIGHT("0" + (DT_STR,4,1252)DATEPART(
"mm" , getdate() ), 2) +"/"+<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;">RIGHT("0" + (DT_STR,4,1252)DATEPART(
"dd" , getdate() ), 2) <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;">+"/"+(DT_STR,4,1252)DATEPART( "yyyy"
, getdate() )<o:p></o:p></span></div>
</div>
Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com0tag:blogger.com,1999:blog-1347602528429387759.post-84281985656283443452018-05-25T03:01:00.000-07:002018-05-25T03:01:45.490-07:00Mostly used Expression in SSIS<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<span style="color: #333333; font-family: Arial;"><span style="color: black; font-family: Times New Roman;">
</span><br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;"><span style="color: black;">SSIS Mostly used expressions:<o:p></o:p></span></span></div>
<span style="color: black; font-family: Times New Roman;">
</span><br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 12pt;">
<span lang="EN" style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-ansi-language: EN; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><span style="color: black;">Here are few examples of expressions for SSIS.<o:p></o:p></span></span></div>
<span style="color: black; font-family: Times New Roman;">
</span><br />
<span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><span style="font-family: Times New Roman;">
</span><table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; border: currentColor; mso-border-alt: solid black .75pt; mso-padding-alt: 0cm 0cm 0cm 0cm; mso-yfti-tbllook: 1184; width: 603px;"><tbody>
<tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0;"><td style="background: silver; border: 1pt solid black; mso-border-alt: solid black .75pt; padding: 0cm; width: 311.95pt;" valign="top" width="416"><span style="font-family: Times New Roman;">
</span><div align="center" class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; text-align: center;">
<b><span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Example<o:p></o:p></span></b></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background: silver; border-color: black black black rgb(0, 0, 0); border-style: solid solid solid none; border-width: 1pt 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; padding: 0cm; width: 140.15pt;" valign="top" width="187"><span style="font-family: Times New Roman;">
</span><div align="center" class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; text-align: center;">
<b><span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Description<o:p></o:p></span></b></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 1;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">"C:\\Project\\DataFile"
+ (DT_WSTR, 30)(DT_DBDATE)GETDATE() + ".csv"<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">This
will provide a File path with current date in file name as C:\Project\ DataFile2018-05-25.csv<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 2;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">ROUND(Amount,
2)<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Round
of two decimal places for a given value/column<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 3;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="background: white; line-height: 12.75pt; margin: 0cm 0cm 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; vertical-align: top;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">"C:\\XYZ\\Files\\" +
(DT_WSTR,4)YEAR(DATEADD("dd", -1, GETDATE())) + "-" <o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="background: white; line-height: 12.75pt; margin: 0cm 0cm 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; vertical-align: top;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><span style="mso-spacerun: yes;"> </span>+
RIGHT("0" + (DT_WSTR,2)MONTH(DATEADD("dd", -1,
GETDATE())), 2) + "-" <o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><span style="mso-spacerun: yes;"> </span>+ RIGHT("0" +
(DT_WSTR,2)DAY(DATEADD("dd", -1, GETDATE())), 2) + ".txt"<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="background: white; line-height: 12.75pt; margin: 0cm 0cm 10pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; vertical-align: top;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">An expression, but this time
deriving the file name based on yesterday’s date, useful for loading the
previous day's data:<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">C:\XYZ\Files\2018-05-24.txt<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 4;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">ISNULL(ColumnName)||TRIM(ColumnName)==""?"Unknown":
ColumnName<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">In this
example, the statement determines that if the ColumnName is blank or NULL, it
will be set to unknown. To make a Logical AND condition, use
"&&" instead of the "||" operator.<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 5;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">(DT_DBTIMESTAMPOFFSET,3)
"1999-10-11 20:34:52.123 -3:30" !=
(DT_DBDATE)"1999-10-12"<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">The
system converts the expression,(DT_DBDATE)"1999-10-12", to
DT_DBTIMESTAMPOFFSET. The example evaluates to TRUE because the converted
expression becomes "1999-10-12 00:00:00.000 +00:00", which is not
equal to the value of the other expression,(DT_DBTIMESTAMPOFFSET,3)
"1999-10-11 20:34:52.123 -3:30".<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 6;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">(DT_I4)
3.57<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Casts a
numeric value to an integer.<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 7;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">(DT_STR,1,1252)5<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Casts
an integer to a character string using the 1252 code page.<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 8;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">(DT_WSTR,3)"Cat"<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Casts a
three-character string to double-byte characters.<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 9;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">(DT_DECIMAl,2)500<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Casts
an integer to a decimal with a scale of two.<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 10;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">(DT_NUMERIC,7,3)4000<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Casts
an integer to a numeric with a precision of seven and scale of three.<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 11;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">(DT_STR,50,1252)FirstName<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Casts
values in the FirstName column, defined with an nvarchar data type and a
length of 50, to a character string using the 1252 code page.<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 12;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">(DT_BOOL)"True"<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Casts
the string literal "True" to a Boolean.<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 13;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">(DT_DBDATE)
"1999-10-11"<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Casts a
string literal to DT_DBDATE.<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 14;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">(DT_DBTIME2,
5) "16:34:52.12345"<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Casts a
string literal to the DT_DBTIME2 data type that uses 5 digits for fractional
seconds. (The DT_DBTIME2 data type can have between 0 and 7 digits specified
for fractional seconds.)<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 15;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">(DT_DBTIMESTAMP2,
4) "1999-10-11 16:34:52.1234"<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Casts a
string literal to the DT_DBTIMESTAMP2 data type that uses 4 digits for
fractional seconds. (The DT_DBTIMESTAMP2 data type can have between 0 and 7
digits specified for fractional seconds.)<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 16;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">(DT_DBTIMESTAMPOFFSET,
7) "1999-10-11 16:34:52.1234567 + 5:35"<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Casts a
string literal to the DT_DBTIMESTAMPOFFSET data type that uses 7 digits for
fractional seconds. (The DT_DBTIMESTAMPOFFSET data typecan have between 0 and
7 digits specified for fractional seconds.)<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 17;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">DATEADD("Month",
1,GETDATE())<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Adds one
month to the current date.<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 18;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">DATEADD("day",
21, ModifiedDate)<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Adds 21
days to the dates in theModifiedDate column.<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 19;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">DATEADD("yyyy",
2, (DT_DBTIMESTAMP)"8/6/2003")<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Adds 2
years to a literal date.<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 20;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">DATEDIFF("dd",
(DT_DBTIMESTAMP)"8/1/2003", (DT_DBTIMESTAMP)"8/8/2003")<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Calculates
the number of days between two date literals. If the date is in
"mm/dd/yyyy" format, the function returns 7.<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 21;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">DATEDIFF("mm",
(DT_DBTIMESTAMP)"8/1/2003",GETDATE())<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Returns
the number of months between a date literal and the current date.<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 22;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">DATEDIFF("Week",
ModifiedDate,@YearEndDate)<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Returns
the number of weeks between the date in theModifiedDate column and
theYearEndDate variable. IfYearEndDate has a date data type, no explicit
casting is required.<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 23;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">DATEPART("month",
(DT_DBTIMESTAMP)"11/04/2002")<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Returns
the integer that represents the month in a date literal. If the date is in
mm/dd/yyyy" format, this example returns 11.<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 24;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">DATEPART("dd",
ModifiedDate)<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Returns
the integer that represents the day in theModifiedDate column.<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 25;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">DATEPART("yy",GETDATE())<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Returns
the integer that represents the year of the current date.<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 26;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">DAY((DT_DBTIMESTAMP)GETDATE())==1||DAY((DT_DBTIMESTAMP)GETDATE())==15?1:2<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Can be
used to set the LoggingMode property of a package. The expression uses the
DAY and GETDATE functions to get an integer that represents the day datepart
of a date. If the day is the 1st or 15th, logging is enabled; otherwise,
logging is disabled. The value 1 is the integer equivalent of theLoggingMode
enumerator member Enabled, and the value 2 is the integer equivalent of the
member Disabled. You must use the numeric value instead of the enumerator
member name in the expression.<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 27;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">"PExpression-->Package:
("<br />
+ @[System::PackageName] + ") Started:" + (DT_WSTR, 30)
@[System::StartTime]<br />
+ " Duration:" + (DT_WSTR,10) (DATEDIFF( "ss",
@[System::StartTime] , GETDATE() ))<br />
+ " seconds"<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Can be
used to set the Subjectproperty of a Send Mail task and provide a useful
e-mail subject. The expression uses a combination of string literals, system
variables, the concatenation (+) and cast operators, and the DATEDIFF and
GETDATE functions. The system variables are the PackageNameand StartTime
variables.<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 28;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">"Rows
Processed: "<br />
+ "\n" +" NASDAQ: "<br />
+ (dt_wstr,9)@[nasdaqrawrows]<br />
+ "\n" + " NYSE: "<br />
+ (dt_wstr,9)@[nyserawrows]<br />
+ "\n" + " Amex: " + (dt_wstr,9)@[amexrawrows]<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Can be
used to set theMessageSource property of a Send Mail task. The expression
uses a combination of string literals, user-defined variables, and the
concatenation (+) operator. The user-defined variables are namednasdaqrawrows,nyserawrows,
andamexrawrows. The string "\n" indicates a carriage return.<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 29;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">DATEPART("weekday",
GETDATE()) ==2?"notepad.exe":"mspaint.exe"<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Can be
used to set theExecutable property of an Execute Process task. The expression
uses a combination of string literals, operators, and functions. The
expression uses the DATEPART and GETDATE functions and the conditional
operator.<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
<tr style="mso-yfti-irow: 30; mso-yfti-lastrow: yes;"><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black; border-style: none solid solid; border-width: 0px 1pt 1pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">(DATEPART("DW",GETDATE())
== 7) ? "SUNDAY" : (DATEPART("DW",GETDATE()) == 1) ?
"MONDAY" : (DATEPART("DW",GETDATE()) == 2) ?
"TUESDAY" : (DATEPART("DW",GETDATE()) == 3) ?
"WEDNESDAY" : (DATEPART("DW",GETDATE()) == 4) ?
"THURSDAY" : (DATEPART("DW",GETDATE()) == 5) ?
"FRIDAY" : (DATEPART("DW",GETDATE()) == 6) ?
"SATURDAY" : "NULL"<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td><td style="background-color: transparent; border-color: rgb(0, 0, 0) black black rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 0cm;" valign="top"><span style="font-family: Times New Roman;">
</span><div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"> Weekday
name<o:p></o:p></span></div>
<span style="font-family: Times New Roman;">
</span></td></tr>
</tbody></table>
<span style="color: black; font-family: Times New Roman;">
</span></span><br /></div>
Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com0tag:blogger.com,1999:blog-1347602528429387759.post-57429940492881661552018-05-25T02:32:00.000-07:002018-05-25T02:32:15.371-07:00Month Name and Day Name in SSIS expression<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<b><u><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 10pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Month Name and Day Name in SSIS expression:<o:p></o:p></span></u></b></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 10pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 10pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">In many scenarios
we need to evaluate month name or days name from date in SSIS expression, for an
example, we have to pick file from a shared location where folder name is based
on current month so in that case we need month name as per date to access that
folder with month name as:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 10pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">C:\abc\Files\2018\May\Monday\ABC.txt<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 10pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">So here you can see
we have to access folder May and then if today is Monday then need to pick file
from Monday folder so for this we can create a variable in SSIS package and use
below expression to define path as:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">"C:\\abc\\File\\
" + (DT_WSTR, 4) YEAR( Getdate()) +"\\"+<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">(MONTH(getdate())
== 1 ? "01. Jan" : MONTH(getdate()) == 2 ? "02. Feb" :
MONTH(getdate()) == 3 ? "03. Mar" : <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><span style="mso-spacerun: yes;"> </span>MONTH(getdate()) == 4 ? "04. Apr" :
MONTH(getdate()) == 5 ? "05. May" : MONTH(getdate()) == 6 ? "06.
June" : <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><span style="mso-spacerun: yes;"> </span>MONTH(getdate()) == 7 ? "07. July"
: MONTH(getdate()) == 8 ? "08. Aug" : MONTH(getdate()) == 9 ?
"09. Sep" : <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><span style="mso-spacerun: yes;"> </span>MONTH(getdate()) == 10 ? "10. Oct"
: MONTH(getdate()) == 11 ? "11. Nov" : MONTH(getdate()) == 12?
"12. Dec":"")<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">+"\\"+
(DATEPART("dw",GETDATE())==1? "Sunday":
DATEPART("dw",GETDATE())==2?"Monday":<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">DATEPART("dw",GETDATE())==3?"Tuesday":
DATEPART("dw",GETDATE())==4?"Wednesday":<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">DATEPART("dw",GETDATE())==5?"Thursday":
DATEPART("dw",GETDATE())==6?"Friday":<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">DATEPART("dw",GETDATE())==7?"Saturday":""
)<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">+"\\ABC.txt
"<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p> </o:p></span></div>
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 10pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Here in above code,
you can see I have used two functions to find Month name and Day name to create
path.<o:p></o:p></span><br />
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 10pt; mso-bidi-font-style: italic; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Below are expressions:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<b><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Expressions for Month Name:<o:p></o:p></span></b></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #000099; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">(MONTH(getdate()) == 1 ? "Jan" : </span><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #000099; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">MONTH(getdate()) == 2 ? "Feb" :</span><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #000099; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">MONTH(getdate()) == 3 ? "Mar" : </span><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #000099; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">MONTH(getdate()) == 4 ? "Apr" : </span><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #000099; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">MONTH(getdate()) == 5 ? "May" :</span><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #000099; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">MONTH(getdate()) == 6 ? "Jun" : </span><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #000099; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">MONTH(getdate()) == 7 ? "Jul" : </span><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #000099; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">MONTH(getdate()) == 8 ? "Aug" : </span><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #000099; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">MONTH(getdate()) == 9 ? "Sep" : </span><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #000099; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">MONTH(getdate()) == 10 ? "Oct" : </span><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #000099; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">MONTH(getdate()) == 11 ? "Nov" : </span><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 10pt;">
<span style="color: #000099; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">MONTH(getdate()) == 12? "Dec":"")</span><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></div>
<b><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"></span></b><br />
<b><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"></span></b><br />
<b><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">Expressions for Day Name:<o:p></o:p></span></b><br />
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><br />
</span><span style="color: #000099; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">DATEPART("dw",GETDATE())==1?
"Sunday":</span><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span><br />
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #000099; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">DATEPART("dw",GETDATE())==2?"Monday":</span><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #000099; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">DATEPART("dw",GETDATE())==3?"Tuesday":</span><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #000099; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">DATEPART("dw",GETDATE())==4?"Wednesday":</span><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #000099; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">DATEPART("dw",GETDATE())==5?"Thursday":</span><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: #000099; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">DATEPART("dw",GETDATE())==6?"Friday":</span><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 10pt;">
<span style="color: #000099; font-family: "Arial","sans-serif"; font-size: 9pt; mso-bidi-font-style: italic; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;">DATEPART("dw",GETDATE())==7?"Saturday":""</span><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 9pt; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<o:p><span style="font-family: Calibri;"> </span></o:p></div>
</div>
Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com2tag:blogger.com,1999:blog-1347602528429387759.post-1771695485147852232018-05-17T08:09:00.001-07:002018-05-17T08:09:43.438-07:00Query performance approach in SQL Server - Simplest way to improve query performance - Part 1<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<b style="mso-bidi-font-weight: normal;"><u><span style="color: #376092; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-color: #376092; mso-style-textfill-fill-themecolor: accent1; mso-themecolor: accent1; mso-themeshade: 191;"><span style="font-family: Calibri;">Simplest way to tune
SQL Query Part 1<o:p></o:p></span></span></u></b></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">If your query is running slow than you can use following ways
to improve its performance. These are my real time scenarios where I got
success by implementing these methods to improve performance of the query.<o:p></o:p></span></div>
<span style="font-family: Calibri;"><b style="mso-bidi-font-weight: normal;">Method 1:</b> Avoid “Select
* from”, use column name i.e. Select Column1, Column2…:<o:p></o:p></span><br />
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">To fetch the result suppose if you are having 10 columns in
your table and you need only 5 out of 10 for your result than use all 5 columns
name only separated by comma in Select statement instead of using as:<o:p></o:p></span></div>
<span style="font-family: Calibri;">Correct Method:<o:p></o:p></span><br />
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Select</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Emp</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">FirstName</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Emp</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">LastName</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Emp</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Salary</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Dept</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">DeptName <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">FROM</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">As</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Emp<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">LEFT</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">JOIN</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> #Dept </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">As</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> Dept<span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">ON</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> Emp</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">DeptID</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">Dept</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">DeptID</span><o:p></o:p></div>
<span style="font-family: Calibri;">Incorrect Method:<o:p></o:p></span><br />
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">SELECT</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">*</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">FROM</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">As</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Emp<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">LEFT</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">JOIN</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> #Dept </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">As</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> Dept<span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">ON</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> Emp</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">DeptID</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">Dept</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">DeptID</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;"><b style="mso-bidi-font-weight: normal;">Method 2:</b> Use Key
columns (Index columns) for filter and join:<o:p></o:p></span></div>
<span style="font-family: Calibri;">If you have indexes in your tables which you are querying or
joining, then try to use those columns if possible for joining condition and
use in where clause to filter data, this will increase performance of your
query.<o:p></o:p></span><br />
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;"><b style="mso-bidi-font-weight: normal;">Method 3:</b> Never
use Cast or convert in Where clause and in Join condition:<o:p></o:p></span></div>
<span style="font-family: Calibri;">Suppose if you have Date filter in your table and if you are
using Cast or Convert operator while filtering your data than you should avoid
it. It will make your query much slower. And same for Join condition also.<o:p></o:p></span><br />
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;"><b style="mso-bidi-font-weight: normal;">Method 4:</b> Use CTE
result set for big table or expression based table to join with other table:<o:p></o:p></span></div>
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Select</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Column1</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Column2</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,.....</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">ColumnN<o:p></o:p></span><br />
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">From</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> TableA <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">left</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">join</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> TableB<span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">on</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> TableA</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">ColumnN </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> TableB</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">ColumnN<span style="mso-spacerun: yes;"> </span><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">left</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">join</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> TableC<span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">on</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> TableB</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">ColumnN </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> TableC</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">ColumnN <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">left</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">join</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> TableD<span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">on</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> TableC</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">ColumnN </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> TableD</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">ColumnN <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">Where</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> TableA</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">Column1 </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> 0 </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">and</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> TableA</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">.</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">Date</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">>=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">'01/01/2018'</span><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">As per given above query example; we have four <span style="mso-spacerun: yes;"> </span>tables to join with each other based on
conditions so first table here is a big table where we have millions records
and another table also big one. But you can see in Where clause, we have
filters for TableA only so If we run this query, than it will take time to give
output so we can re-write in an efficient way with CTE as:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">WITH</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> TableACte<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Select</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Column1</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Column2</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,.....</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">ColumnN<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">From</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> TableA <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Where</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> TableA</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Column1 </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> 0 </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">and</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> TableA</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Date</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">>=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'01/01/2018'</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Select</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Column1</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Column2</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,.....</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">ColumnN<o:p></o:p></span></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">From</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> TableACte<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">left</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">join</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> TableB<span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">on</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> TableACte</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">ColumnN </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> TableB</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">ColumnN<span style="mso-spacerun: yes;"> </span><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">left</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">join</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> TableC<span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">on</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> TableB</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">ColumnN </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> TableC</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">ColumnN <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">left</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">join</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> TableD<span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">on</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> TableC</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">ColumnN </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> TableD</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">ColumnN</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;"><b style="mso-bidi-font-weight: normal;"><u>NOTE:</u></b> In
my Scenario, My query was taking 12 minutes to execute and now with this
approach, it is giving result in less than 1 minute as Data is in billions.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: Calibri;">Method 5: Avoid Case
or any expression i.e. If condition in Where and Join condition<o:p></o:p></span></b></div>
<span style="font-family: Calibri;">If you are using Case or If condition in Where clause or
Join condition in your query than it will make your query very slow if data is
huge because for each row it will calculate condition and will apply for filter
in Where clause and join condition. So find alternate ways to do same or you
can use sub query to build derived column.<o:p></o:p></span><br />
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: Calibri;">Method 6: Try to use
non-text columns for where clause and Join condition, use only Key columns
where Datatype is not varchar() or nvarchar().<o:p></o:p></span></b></div>
<span style="font-family: Calibri;">Always best method to use non text columns for join condition
and if possible for Where clause also for filtering data because Text value
will take time to get filter and join data.<o:p></o:p></span><br />
<br />
Stay Tune for more methods in next part....<br />
</div>
Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com0tag:blogger.com,1999:blog-1347602528429387759.post-71826311054734969272018-05-17T02:26:00.000-07:002018-05-17T02:26:30.668-07:00CROSS APPLY and OUTER APPLY in SQL SERVER<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<b style="mso-bidi-font-weight: normal;"><u><span style="color: #376092; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-color: #376092; mso-style-textfill-fill-themecolor: accent1; mso-themecolor: accent1; mso-themeshade: 191;"><span style="font-family: Calibri;">CROSS APPLY and
OUTER APPLY in SQL SERVER.<o:p></o:p></span></span></u></b></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">Apply operator in SQL server introduced in version 2005.
This operator gives you flexibility to join two table expressions where right
table expression is processed every time row by row from the left table
expression<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">Left table expression is evaluated first and then right
table expression is evaluated against each row of the left table expression for
final result-set.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">There are two types of Apply operators in SQL server:<o:p></o:p></span></div>
<br />
<div class="MsoListParagraphCxSpFirst" style="margin: 0cm 0cm 0pt 36pt; mso-list: l0 level1 lfo1; text-indent: -18pt;">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;"><span style="mso-list: Ignore;">·<span style="font-size-adjust: none; font-stretch: normal; font: 7pt/normal "Times New Roman";">
</span></span></span><!--[endif]--><b style="mso-bidi-font-weight: normal;"><span style="font-family: Calibri;">CROSS
APPLY<o:p></o:p></span></b></div>
<br />
<div class="MsoListParagraphCxSpLast" style="margin: 0cm 0cm 10pt 36pt; mso-list: l0 level1 lfo1; text-indent: -18pt;">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;"><span style="mso-list: Ignore;">·<span style="font-size-adjust: none; font-stretch: normal; font: 7pt/normal "Times New Roman";">
</span></span></span><!--[endif]--><b style="mso-bidi-font-weight: normal;"><span style="font-family: Calibri;">OUTER
APPLY<o:p></o:p></span></b></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">CROSS APPLY acts like an INNER JOIN, and OUTER APPLY acts
like a LEFT OUTER JOIN.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">Let’s understand functionality of Cross Apply and Outer
Apply with examples:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">Let’s take an example of Cross Apply first to understand it
in a better way by comparison with Inner Join query. As we know CROSS APPLY
operator acts same as Inner Join here in example we have two tables: Employee
and Department<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">To join Employee Table with Department by Inner Join
operator:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<b style="mso-bidi-font-weight: normal;"><u><span style="font-family: Calibri;">NOTE: At the end of
this article you will find Sample query to build Employee and Department table
for Practice.<o:p></o:p></span></u></b></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">SELECT</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">*</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">FROM</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">As</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Emp<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">INNER</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">JOIN</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> Department </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">As</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> Dept<span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">ON</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> Emp</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">DeptID</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">Dept</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">DeptID</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">Cross Apply to join Employee Table with Department:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">SELECT</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">*</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">FROM</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">as</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Emp<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">CROSS</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">APPLY</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">(</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">SELECT</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">*</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">FROM</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> Department </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">As</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> Dept </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">WHERE</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> Emp</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">DeptID</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">Dept</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">DeptID</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> Dept</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">Now you will say these both query works same than why we
need complex code of Corss Apply whenever we have Inner Join as simple so let’s
take one scenario as:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">Suppose if want to see Top 2 salary for each Department
where Salary is in Empoloyee table and Department we have in Department Table.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">With Cross Apply, by writing Simple Query we can achieve
result as:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Select</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Dept</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">DeptName</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Emp</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Salary </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">from</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Dept </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">as</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Dept<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">CROSS</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">APPLY</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">SELECT</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Top</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> 3 </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">*</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">FROM</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">As</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Emp </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">WHERE</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Emp</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">DeptID</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Dept</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">DeptID</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Emp<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">Order</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">By</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> Dept</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">DeptName</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">Emp</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">Salary</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">Result will be as:<o:p></o:p></span></div>
<br />
<table border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; margin: auto auto auto 4.65pt; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-yfti-tbllook: 1184; width: 153px;">
<tbody>
<tr style="height: 15pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0;">
<td nowrap="" style="background: rgb(54, 96, 146); border: 1pt solid windowtext; height: 15pt; mso-border-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 67pt;" valign="bottom" width="89">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<b><span style="color: white; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">DeptName<o:p></o:p></span></span></b></div>
</td>
<td nowrap="" style="background: rgb(54, 96, 146); border-color: windowtext windowtext windowtext rgb(0, 0, 0); border-style: solid solid solid none; border-width: 1pt 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 48pt;" valign="bottom" width="64">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<b><span style="color: white; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Salary<o:p></o:p></span></span></b></div>
</td>
</tr>
<tr style="height: 15pt; mso-yfti-irow: 1;">
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 67pt;" valign="bottom" width="89">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">IT Analytics<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 48pt;" valign="bottom" width="64">
<div align="right" class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; text-align: right;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">19000<o:p></o:p></span></span></div>
</td>
</tr>
<tr style="height: 15pt; mso-yfti-irow: 2;">
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 67pt;" valign="bottom" width="89">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">IT Analytics<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 48pt;" valign="bottom" width="64">
<div align="right" class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; text-align: right;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">20000<o:p></o:p></span></span></div>
</td>
</tr>
<tr style="height: 15pt; mso-yfti-irow: 3;">
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 67pt;" valign="bottom" width="89">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">IT Analytics<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 48pt;" valign="bottom" width="64">
<div align="right" class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; text-align: right;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">35000<o:p></o:p></span></span></div>
</td>
</tr>
<tr style="height: 15pt; mso-yfti-irow: 4;">
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 67pt;" valign="bottom" width="89">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">IT Apps<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 48pt;" valign="bottom" width="64">
<div align="right" class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; text-align: right;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">15000<o:p></o:p></span></span></div>
</td>
</tr>
<tr style="height: 15pt; mso-yfti-irow: 5;">
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 67pt;" valign="bottom" width="89">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">IT Apps<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 48pt;" valign="bottom" width="64">
<div align="right" class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; text-align: right;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">18000<o:p></o:p></span></span></div>
</td>
</tr>
<tr style="height: 15pt; mso-yfti-irow: 6; mso-yfti-lastrow: yes;">
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 67pt;" valign="bottom" width="89">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">IT Apps<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 48pt;" valign="bottom" width="64">
<div align="right" class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; text-align: right;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">26000<o:p></o:p></span></span></div>
</td>
</tr>
</tbody></table>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">Now we look at below query without CROSS APPLY, where we
have to use Rank or Row Number function to achieve the same result:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">SELECT</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Sal</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">DeptName</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Sal</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Salary </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">FROM </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">SELECT</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Dept</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">DeptName</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Emp</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Salary </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">ROW_NUMBER</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">()</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">OVER </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">PARTITION</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">BY</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Dept</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">DeptName </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">ORDER</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">BY</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Emp</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Salary </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Desc</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> RN<span style="mso-spacerun: yes;"> </span><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">FROM</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">as</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Emp<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">INNER</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">JOIN</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Dept </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">As</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Dept </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">ON</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Emp</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">DeptID</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Dept</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">DeptID<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Sal<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">WHERE</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> Sal</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">RN </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"><=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> 3</span><span style="color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">Benefits of Using CROSS APPLY:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">We can use TOP operator with CROSS APPLY where it will
return TOP N rows for each matching row and no need to use partitioning for
using Rank or Row number to short.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">OUTER APPLY<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">OUTER APPLY is similar to Left Join in SQL Server as OUTER
APPLY operator in SQL Server returns all rows from the LEFT table expression.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">Syntax for OUTER APPLY as:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Calibri;">Simple Query with Left
Join:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<o:p><span style="font-family: Calibri;"> </span></o:p></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">SELECT</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">*</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">FROM</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">As</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Emp<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">LEFT</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">JOIN</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Dept </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">As</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Dept<span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">ON</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Emp</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">DeptID</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Dept</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">DeptID<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Calibri;">Outer Apply Logic to
achieve same result as Left join<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">SELECT</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">*</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">FROM</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">as</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Emp<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">OUTER</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">APPLY</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">(</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">SELECT</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">*</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">FROM</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> #Dept </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">As</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> Dept </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">WHERE</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> Emp</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">DeptID</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">Dept</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">DeptID</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> Dept</span><o:p></o:p></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">Drawback of Using Apply Operator:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">As apply operator are process row by row so it will be
slower than Join.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<b style="mso-bidi-font-weight: normal;"><u><span style="font-family: Calibri;">Sample Data query
for Employee and Department Table:<o:p></o:p></span></u></b></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Create</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Table</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">EmpID
</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">int</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">FirstName
</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">varchar</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">20</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">),</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">LastName
</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">varchar</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">30</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">),</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Gender
</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">varchar</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">10</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">),</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Salary
</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">int</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">DeptID
</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">int</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">ManagerID
</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">int</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Values </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">11</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Sonu'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Kumar'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'M'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">10000</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">113</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">16</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Values </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">12</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Ritu'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Singh'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'F'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">15000</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">112</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">15</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Values </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">13</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Parul'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Sharma'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'F'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">12000</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">113</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">16</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Values </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">14</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Sanjay'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Kumar'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'M'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">18000</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">112</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">15</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Values </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">15</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Ajay'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Singh'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'M'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">20000</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">114</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">24</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Values </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">16</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Vijay'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Sehgal'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'M'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">26000</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">114</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">24</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Values </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">17</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Kishor'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Kullar'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'M'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">19000</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">115</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">28</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Values </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">18</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Pramod'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Jha'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'M'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">26000</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">112</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">15</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Values </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">19</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Jai'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Kumar'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'M'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">15000</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">113</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">16</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Values </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">20</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Ram'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Singh'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'M'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">12000</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">114</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">24</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Values </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">21</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Sunil'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Verma'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'M'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">18000</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">113</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">16</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Values </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">22</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Maynak'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'singh'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'M'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">20000</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">115</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">28</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Values </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">23</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Prabhu'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Sharma'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'M'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">26000</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">112</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">15</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Values </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">24</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Ankita'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Kumar'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'F'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">35000</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">115</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">28</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Values </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">25</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Anu'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Singh'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'F'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">19000</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">112</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">15</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Values </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">26</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Pooja'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Verma'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'F'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">26000</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">115</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">28</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Values </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">27</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Kamal'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Singh'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'M'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">31000</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">112</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">15</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Values </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">28</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Sunita'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Rajpal'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'F'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">42000</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">115</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">28</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Values </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">29</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Kritika'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Kalra'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'F'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">18000</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">114</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">24</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Values </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">30</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Shilpa'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Tripathi'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'F'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">20000</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">114</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">24</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Create</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Table</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Dept<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">DeptID
</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">int</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">DeptName
</span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">varchar</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">30</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Dept </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Values </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">112</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'IT Apps'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Dept </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Values </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">113</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'IT Testing'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Dept </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Values </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">114</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'IT Mainframe'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Insert</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">into</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Dept </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Values </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">115</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'IT Analytics'</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Select</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">*</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">from</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> #Employee<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p> </o:p></span></div>
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-highlight: white;">Select</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-highlight: white;">*</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-highlight: white;">from</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-highlight: white;"> #Dept</span></div>
Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com0tag:blogger.com,1999:blog-1347602528429387759.post-7246041400353247362018-05-16T03:48:00.000-07:002018-05-16T03:48:27.002-07:00Schema query to find all tables with column names in all database in SQL Server<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<b style="mso-bidi-font-weight: normal;"><u><span style="font-family: Calibri;"><span style="color: #376092; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-color: #376092; mso-style-textfill-fill-themecolor: accent1; mso-themecolor: accent1; mso-themeshade: 191;">Schema Query to find
<span style="mso-spacerun: yes;"> </span>all Tables from all database with column
name and schema.</span><o:p></o:p></span></u></b></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">Below Query will provide all tables with their Database,
Schema and columns from all databases in your SQL Server<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: maroon; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">sp_msforeachdb</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'select "?" AS
[Database Name],</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">t.name
AS [Table Name],</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">SCHEMA_NAME(schema_id)
AS [Schema Name],</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">c.name
AS [Column Name],</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">''[''+
DB_name() +''].[''+SCHEMA_NAME(schema_id)+''].[''+t.name+'']'' as Query_String</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">From
[?].sys.tables t</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">INNER
JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID </span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">Where "?"
not in (''master'', ''model'',''msdb'',''tempdb'')'</span><span style="color: magenta; font-family: Consolas; font-size: 9.5pt; line-height: 115%;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">Result will be as:<o:p></o:p></span></div>
<br />
<table border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; margin: auto auto auto 4.65pt; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-yfti-tbllook: 1184; width: 849px;">
<tbody>
<tr style="height: 15pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0;">
<td nowrap="" style="background: rgb(54, 96, 146); border: 1pt solid windowtext; height: 15pt; mso-border-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 57.45pt;" valign="bottom" width="77">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<b><span style="color: white; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Database Name<o:p></o:p></span></span></b></div>
</td>
<td nowrap="" style="background: rgb(54, 96, 146); border-color: windowtext windowtext windowtext rgb(0, 0, 0); border-style: solid solid solid none; border-width: 1pt 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<b><span style="color: white; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Table Name<o:p></o:p></span></span></b></div>
</td>
<td nowrap="" style="background: rgb(54, 96, 146); border-color: windowtext windowtext windowtext rgb(0, 0, 0); border-style: solid solid solid none; border-width: 1pt 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<b><span style="color: white; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Schema Name<o:p></o:p></span></span></b></div>
</td>
<td nowrap="" style="background: rgb(54, 96, 146); border-color: windowtext windowtext windowtext rgb(0, 0, 0); border-style: solid solid solid none; border-width: 1pt 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<b><span style="color: white; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Column Name<o:p></o:p></span></span></b></div>
</td>
<td nowrap="" style="background: rgb(54, 96, 146); border-color: windowtext windowtext windowtext rgb(0, 0, 0); border-style: solid solid solid none; border-width: 1pt 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 388.05pt;" valign="bottom" width="517">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<b><span style="color: white; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Query for Top 10 Records<o:p></o:p></span></span></b></div>
</td>
</tr>
<tr style="height: 15pt; mso-yfti-irow: 1;">
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 57.45pt;" valign="bottom" width="77">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">ABC<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Employee<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">HR<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">EMPID<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 388.05pt;" valign="bottom" width="517">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Select Top 10 * From
[ABC].[HR].[EMPID]<o:p></o:p></span></span></div>
</td>
</tr>
<tr style="height: 15pt; mso-yfti-irow: 2; mso-yfti-lastrow: yes;">
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 57.45pt;" valign="bottom" width="77">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">ABC<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Employee<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">HR<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">FirstName<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 388.05pt;" valign="bottom" width="517">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Select Top 10 * From<span style="mso-spacerun: yes;"> </span>[ABC].[HR].[FirstName]<o:p></o:p></span></span></div>
</td>
</tr>
</tbody></table>
</div>
Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com0tag:blogger.com,1999:blog-1347602528429387759.post-53148983165310871812018-05-16T02:25:00.001-07:002018-05-16T02:25:53.158-07:00Schema query to find all Tables with their columns details in SQL Server<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<b style="mso-bidi-font-weight: normal;"><u><span style="font-family: Calibri;"><span style="color: #376092; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-color: #376092; mso-style-textfill-fill-themecolor: accent1; mso-themecolor: accent1; mso-themeshade: 191;">Schema Query to get
details like columns, schema and Table name about all Tables with in a Database</span><o:p></o:p></span></u></b></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">First changes your database name here in first line of Code,
where you want to fetch views details:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">USE</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> [DatabaseName]<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">SELECT</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">DB_name</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">()</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">as</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> [Database Name]</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">t</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">name </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">AS</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> [Table Name]</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">SCHEMA_NAME</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">schema_id</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">AS</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> [Schema Name]</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">c</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">name </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">AS</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> [Column Name]</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'['</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">+</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">DB_name</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">()</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">+</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'].['</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">+</span><span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">SCHEMA_NAME</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">schema_id</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)+</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'].['</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">+</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">t</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">name</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">+</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">']'</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">as</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Query_String<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">FROM</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: lime; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">sys</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: lime; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">tables</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">AS</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> t<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">INNER</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">JOIN</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: lime; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">sys</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: lime; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">columns</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> c </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">ON</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> t</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">OBJECT_ID</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> c</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">OBJECT_ID</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">ORDER</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">BY</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span>[Schema Name]</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> [Table
Name]</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">;</span><span style="color: magenta; font-family: Consolas; font-size: 9.5pt; line-height: 115%;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">Result will be as:<o:p></o:p></span></div>
<br />
<table border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; margin: auto auto auto 4.65pt; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-yfti-tbllook: 1184; width: 849px;">
<tbody>
<tr style="height: 15pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0;">
<td nowrap="" style="background: rgb(54, 96, 146); border: 1pt solid windowtext; height: 15pt; mso-border-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 57.45pt;" valign="bottom" width="77">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<b><span style="color: white; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Database Name<o:p></o:p></span></span></b></div>
</td>
<td nowrap="" style="background: rgb(54, 96, 146); border-color: windowtext windowtext windowtext rgb(0, 0, 0); border-style: solid solid solid none; border-width: 1pt 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<b><span style="color: white; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Table Name<o:p></o:p></span></span></b></div>
</td>
<td nowrap="" style="background: rgb(54, 96, 146); border-color: windowtext windowtext windowtext rgb(0, 0, 0); border-style: solid solid solid none; border-width: 1pt 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<b><span style="color: white; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Schema Name<o:p></o:p></span></span></b></div>
</td>
<td nowrap="" style="background: rgb(54, 96, 146); border-color: windowtext windowtext windowtext rgb(0, 0, 0); border-style: solid solid solid none; border-width: 1pt 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<b><span style="color: white; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Column Name<o:p></o:p></span></span></b></div>
</td>
<td nowrap="" style="background: rgb(54, 96, 146); border-color: windowtext windowtext windowtext rgb(0, 0, 0); border-style: solid solid solid none; border-width: 1pt 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 388.05pt;" valign="bottom" width="517">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<b><span style="color: white; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Query for Top 10 Records<o:p></o:p></span></span></b></div>
</td>
</tr>
<tr style="height: 15pt; mso-yfti-irow: 1;">
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 57.45pt;" valign="bottom" width="77">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">ABC<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Employee<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">HR<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">EMPID<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 388.05pt;" valign="bottom" width="517">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Select Top 10 * From
[ABC].[HR].[EMPID]<o:p></o:p></span></span></div>
</td>
</tr>
<tr style="height: 15pt; mso-yfti-irow: 2; mso-yfti-lastrow: yes;">
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 57.45pt;" valign="bottom" width="77">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">ABC<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Employee<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">HR<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">FirstName<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 388.05pt;" valign="bottom" width="517">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Select Top 10 * From<span style="mso-spacerun: yes;"> </span>[ABC].[HR].[FirstName]<o:p></o:p></span></span></div>
</td>
</tr>
</tbody></table>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<o:p><span style="font-family: Calibri;"> </span></o:p></div>
</div>
Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com0tag:blogger.com,1999:blog-1347602528429387759.post-222892740493234552018-05-16T02:13:00.001-07:002018-05-16T02:13:49.159-07:00Schema query to find all views with their columns details in SQL Server<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<b style="mso-bidi-font-weight: normal;"><u><span style="font-family: Calibri;"><span style="color: #376092; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-color: #376092; mso-style-textfill-fill-themecolor: accent1; mso-themecolor: accent1; mso-themeshade: 191;">Schema Query to get
details like columns, schema and views name about all views with in a Database</span><o:p></o:p></span></u></b></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">First changes your database name here in first line of Code,
where you want to fetch views details:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">USE</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> [DatabaseName]<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">Select</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">DB_name</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">()</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">as</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> [Database Name]</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">v</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">name </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">as</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> [View Name]</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">SCHEMA_NAME</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">schema_id</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">AS</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> [Schema Name]</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">c</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">name </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">AS</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> [Column Name]</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">,</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'Select
Top 10 * From ['</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">+</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">DB_name</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">()</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">+</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'].['</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">+</span><span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">SCHEMA_NAME</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">(</span><span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">schema_id</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">)+</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">'].['</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">+</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">v</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">name</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">+</span><span style="background: white; color: red; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">']'</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">as</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> Query_String<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">from</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"><span style="mso-spacerun: yes;"> </span></span><span style="background: white; color: lime; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">sys</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">.</span><span style="background: white; color: lime; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;">views</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; mso-highlight: white;"> v<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">INNER</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">JOIN</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: lime; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">sys</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">.</span><span style="background: white; color: lime; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">columns</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> c </span><span style="background: white; color: blue; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">ON</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> v</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">.</span><span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">OBJECT_ID</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> </span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">=</span><span style="background: white; color: black; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;"> c</span><span style="background: white; color: grey; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">.</span><span style="background: white; color: magenta; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-highlight: white;">OBJECT_ID</span><span style="color: magenta; font-family: Consolas; font-size: 9.5pt; line-height: 115%;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="color: magenta; font-family: Consolas; font-size: 9.5pt; line-height: 115%;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">Result will be as:<o:p></o:p></span></div>
<br />
<table border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; margin: auto auto auto 4.65pt; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-yfti-tbllook: 1184; width: 849px;">
<tbody>
<tr style="height: 15pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0;">
<td nowrap="" style="background: rgb(54, 96, 146); border: 1pt solid windowtext; height: 15pt; mso-border-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 57.45pt;" valign="bottom" width="77">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<b><span style="color: white; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Database Name<o:p></o:p></span></span></b></div>
</td>
<td nowrap="" style="background: rgb(54, 96, 146); border-color: windowtext windowtext windowtext rgb(0, 0, 0); border-style: solid solid solid none; border-width: 1pt 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<b><span style="color: white; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">View Name<o:p></o:p></span></span></b></div>
</td>
<td nowrap="" style="background: rgb(54, 96, 146); border-color: windowtext windowtext windowtext rgb(0, 0, 0); border-style: solid solid solid none; border-width: 1pt 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<b><span style="color: white; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Schema Name<o:p></o:p></span></span></b></div>
</td>
<td nowrap="" style="background: rgb(54, 96, 146); border-color: windowtext windowtext windowtext rgb(0, 0, 0); border-style: solid solid solid none; border-width: 1pt 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<b><span style="color: white; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Column Name<o:p></o:p></span></span></b></div>
</td>
<td nowrap="" style="background: rgb(54, 96, 146); border-color: windowtext windowtext windowtext rgb(0, 0, 0); border-style: solid solid solid none; border-width: 1pt 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 388.05pt;" valign="bottom" width="517">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<b><span style="color: white; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Query for Top 10 Records<o:p></o:p></span></span></b></div>
</td>
</tr>
<tr style="height: 15pt; mso-yfti-irow: 1;">
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 57.45pt;" valign="bottom" width="77">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">ABC<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Employee<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">HR<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">EMPID<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 388.05pt;" valign="bottom" width="517">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Select Top 10 * From
[ABC].[HR].[EMPID]<o:p></o:p></span></span></div>
</td>
</tr>
<tr style="height: 15pt; mso-yfti-irow: 2; mso-yfti-lastrow: yes;">
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext; border-style: none solid solid; border-width: 0px 1pt 1pt; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 57.45pt;" valign="bottom" width="77">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">ABC<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Employee<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">HR<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 63.8pt;" valign="bottom" width="85">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">FirstName<o:p></o:p></span></span></div>
</td>
<td nowrap="" style="background-color: transparent; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); border-style: none solid solid none; border-width: 0px 1pt 1pt 0px; height: 15pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt; padding: 0cm 5.4pt; width: 388.05pt;" valign="bottom" width="517">
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt;">
<span style="color: black; mso-ascii-font-family: Calibri; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-IN; mso-hansi-font-family: Calibri;"><span style="font-family: Calibri;">Select Top 10 * From<span style="mso-spacerun: yes;"> </span>[ABC].[HR].[FirstName]<o:p></o:p></span></span></div>
</td>
</tr>
</tbody></table>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<o:p><span style="font-family: Calibri;"> </span></o:p></div>
</div>
Avanish Tomarhttp://www.blogger.com/profile/11173516247565853114noreply@blogger.com0