Tuesday, July 5, 2022

Difference between "Maven Install" and "Maven Build"

 First of all, build is not a phase in the standard Maven lifecycles, whereas install is one. mvn install will invoke all the phases up to the phase install, which generally consists of compiling the source code, packaging the project and installing it in the local repository.

To be clear, we're talking about what M2Eclipse shows in the "Run As" selection.

What are all those options? First of all, you need to be aware that you can:

Configure custom "Run Configuration"s in Eclipse

By going to:

This will open a dialog where you can configure those custom configurations.

You can create a new "Maven Build" run configuration, by giving it:

  • a name: this will be the unique name of the configuration. You can name it as you like. Above, it is named with the goals that it will invoke.
  • the base directory: this will be the folder where Maven will be invoked in. In the above screenshot, I used the Eclipse variable ${project_loc}, which is replaced automatically by the base directory of the current selected project in the "Project Explorer" when run. (This allows to have a single run configuration for multiple projects).
  • goals, potential profiles and several options: all those options will make up for the exact command that will be launched. Adding a profile will launch Maven with a -P... attribute; checking "Update Snapshots" will launch Maven with the -U flag, etc.

So what are all those "Run As" options?

Maven install

This is the simple one: "Maven install" will launch the configured Maven installation in Eclipse with the goal install. It will have the same effect as running the command mvn install on the command-line, with an external Maven installation.

The options "Maven generate-sources", "Maven test" or "Maven clean" are actually following the same idea: all of those will directly invoke Maven with the generate-sources phase, the test phase or the clean phase.

Maven build...

This will actually launch the previous dialog where we created a new run configuration. What happens is that M2Eclipse will create a new one, that you can fill exactly like above. You could see it as a short-cut for creating custom "Maven Build" run configurations.

Maven build

This will try to launch the configured custom run configurations.

  • If you have only one custom "Maven Build" run configuration, it will launch that one.
  • If you have more than one, it will ask you for the one to run:

    enter image description here

    In the above screenshots, you can see that there was 2 custom "Maven Build" run configuration, which were named clean and clean install. As such, this pop-up is asking the user to select one.

Once the custom "Maven Build" configuration was chosen, it will then invoke Maven with the options in this run configuration.

Monday, November 19, 2018

MSSQL - Database CPU Usage

Scripts to generate the CPU usage of a database.

DECLARE @ts_now bigint = (SELECT cpu_ticks/(cpu_ticks/ms_ticks)FROM sys.dm_os_sys_info); 

SELECT TOP(30) SQLProcessUtilization AS [SQL Server Process CPU Utilization], 
               SystemIdle AS [System Idle Process], 
               100 - SystemIdle - SQLProcessUtilization AS [Other Process CPU Utilization], 
               DATEADD(ms, -1 * (@ts_now - [timestamp]), GETDATE()) AS [Event Time] 
         SELECT record.value('(./Record/@id)[1]', 'int') AS record_id, 
                     record.value('(./Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int') 
                     AS [SystemIdle], 
                     AS [SQLProcessUtilization], [timestamp] 
         FROM ( 
                     SELECT [timestamp], CONVERT(xml, record) AS [record] 
                     FROM sys.dm_os_ring_buffers 
                     WHERE ring_buffer_type = N'RING_BUFFER_SCHEDULER_MONITOR' 
                     AND record LIKE '%%') AS x 
         ) AS y 
ORDER BY record_id DESC;

Currently the CPU usage is showing per minutes.
To change the CPU usage table to every 10 minutes.
change the value below from -1 to -10.

MSSQL - Get size of all tables in database

below scripts use to generate the all the Database table size and number of rows of records in the table.

use distribution
    t.NAME AS TableName,
    s.Name AS SchemaName,
    p.rows AS RowCounts,
    SUM(a.total_pages) * 8 AS TotalSpaceKB, 
    CAST(ROUND(((SUM(a.total_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS TotalSpaceMB,
    SUM(a.used_pages) * 8 AS UsedSpaceKB, 
    CAST(ROUND(((SUM(a.used_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS UsedSpaceMB, 
    (SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB,
    CAST(ROUND(((SUM(a.total_pages) - SUM(a.used_pages)) * 8) / 1024.00, 2) AS NUMERIC(36, 2)) AS UnusedSpaceMB
    sys.tables t
    sys.indexes i ON t.OBJECT_ID = i.object_id
    sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
    sys.allocation_units a ON p.partition_id = a.container_id
    sys.schemas s ON t.schema_id = s.schema_id
    t.NAME NOT LIKE 'dt%' 
    AND t.is_ms_shipped = 0
    AND i.OBJECT_ID > 255 
    t.Name, s.Name, p.Rows
ORDER BY CAST(ROUND(((SUM(a.total_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) desc

Saturday, December 2, 2017

How tempDB works in MSSQL

Temp table is stored in tempdb until the connection is dropped (or in the case of a global temp tables when the last connection using it is dropped). You can also (and it is a good practice to do so) manually drop the table when you are finished using it with a drop table statement.
No, others cannot see your temp tables if they are local temp tables (They can see and use global temp tables) Multiple people can run commands which use the same temp table name but they will not be overlapping in a local temp table and so you can have a table named #test and so can 10,000 other users, but each one has its own structure and data.
You don't want to generally look up temp tables in tempdb. It is possible to check for existence, but that is the only time I have ever referenced tempdb directly. Simply use your temp table name. Example below of checking for existence
  IF OBJECT_ID('TempDB.dbo.#DuplicateAssignments') IS NOT NULL 
  DROP TABLE #DuplicateAssignments 
You name temp tables by prefacing the name with # (for local tables the ones you would use 999.9% of the time) and ## for global temp tables, then the rest of the name you want.

Tuesday, June 30, 2015

Query to get the names of all tables in SQL

SQL Server 
USE your_database SELECT name FROM sys.tables

SQL Server - get the fields info
       COLUMN_NAME, substring(DATA_TYPE, 1,1) AS DATA_TYPE
FROM information_schema.COLUMNS  



Wednesday, December 26, 2012

Check DB Table Size (sp_spaceused)

Displays the number of rows, disk space reserved, and disk space used by a table, indexed view, or Service Broker queue in the current database, or displays the disk space reserved and used by the whole database.

EXEC sp_spaceused N'Sales.SalesPerson';


Monday, November 19, 2012

Limit - MySQL Command

Limit is used to limit your MySQL query results to those that fall within a specified range. It is use for select number of row of record from your query.

your table record : 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15

SELECT * FROM 'YourTable' Limit 10
- It will select 10 rows of record from the table.

Result : 1,2,3,4,5,6,7,8,9,10

SELECT * FROM 'YourTable' LIMIT 0, 3 
- It will return 3 rows of record and start from index 0

Result : 1,2,3

SELECT * FROM 'YourTable' LIMIT 2, 3 
- It will return 3 rows of record and start from index 2

Result : 3,4,5

Monday, June 11, 2012

The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator

SQL Server Error Message :
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.

In order to compare or sort text/ntext, you need to convert it to varchar (or similar datatype that can allow compare/sort). Note, text/ntext often has a large capacity for data than varchar.

Example SQL Code 1:
[...] ORDER BY TableColumn
change to
[...] ORDER BY cast(TableColumn as varchar(500))

Example SQL Code 2:
[...] GROUP BY TableColumn
change to
[...] GROUP BY cast(TableColumn as varchar(500))

Monday, May 21, 2012

Saving changes is not permitted in SQL 2008 Management Studio

When you design a table in a database and then try to make a change to a table structure that requires the table to be recreated, the Database Management Studio will not allow you to save the changes.
This is caused by a configuration setting that default results in the following dialog:

Error Screen


This is by design and can be quickly fixed in Management Studio by unchecking a property.
To fix this in Management Studio, go to Tools -> Options then go to the Designer Page and uncheck "Prevent saving changes that require table re-creation


Friday, May 18, 2012

SharePoint webparts AJAX enabled?

The web parts in SharePoint 2007 are NOT Ajax enabled.  AJAX support didn't come along for 2007 until SP1.  The web parts weren't re-written to add AJAX to them.  Some of the SharePoint 2010 web parts are AJAX enabled, but not in 2007.

Sunday, May 6, 2012

Add Linked server using Command

A linked server configuration allows Microsoft® SQL Server™ to execute commands against OLE DB data sources on different servers. Linked servers offer these advantages:

  • Remote server access.
  • The ability to issue distributed queries, updates, commands, and transactions on heterogeneous data sources across the enterprise.
  • The ability to address diverse data sources similarly

Creates a linked server. A linked server allows for access to distributed, heterogeneous queries against OLE DB data sources. After a linked server is created by using sp_addlinkedserver, distributed queries can be run against this server. If the linked server is defined as an instance of SQL Server, remote stored procedures can be executed.

EXEC sp_addlinkedserver @server= SERVER NAME

eg, your server name is myDBserver then 
EXEC sp_addlinkedserver @server = 'myDBserver'

Creates or updates a mapping between a login on the local instance of SQL Server and a security account on a remote server.

EXEC sp_addlinkedsrvlogin  @rmtsrvname , 'TRUE' | 'FALSE' | NULL@locallogin@rmtuser

EXEC sp_addlinkedsrvlogin 'myDBserver, 'false', NULL, 'sa', 'password'

Friday, February 17, 2012

Sharepoint - SPSecurityTokenServiceConfig is not recognized

i try to run SET-SPSecurityTokenServiceConfig command in powershell, but it return me error message
" SET-SPSecurityTokenServiceConfig recognized as the name of cmdlet, function..."

Add-PSSnapin Microsoft.SharePoint.Powershell

After this, sharepoint commands will be available in PowerShell.

Wednesday, February 15, 2012

Microsoft.Ace.OLEDB.12.0 and OPENROWSET Errors

If you imports excel file into database using sql query 

INSERT INTO newtable
select  * FROM
OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=C:\temp.xls;HDR=YES', 'SELECT * FROM [sheet$]')

and get below error message

Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "Microsoft.Ace.OLEDB.12.0" for linked server "(null)" reported an error. The provider did not give any information about the error.
Msg 7330, Level 16, State 2, Line 1
Cannot fetch a row from OLE DB provider "Microsoft.Ace.OLEDB.12.0" for linked server "(null)".

please run 2 sql below to solve it

EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1

Monday, January 30, 2012

The OLE DB provider "Microsoft.ACE.OLEDB.12.0" has not been registered

If you run below SQL statement
Select * into DBTable FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=D:\myExcelFile.xlsx;HDR=YES', 'SELECT * FROM [Sheet1$]')

INSERT INTO DBTable select * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=D:\myExcelFile.xlsx;HDR=YES', 'SELECT * FROM [Sheet1$]')

and you get an error message like below
The OLE DB provider "Microsoft.ACE.OLEDB.12.0" has not been registered

you need to download 
"Data Connectivity Components for 2007 office system Driver".
after you download, please restart your server.

you can click link here to download from microsoft site.

you will able to saw your microsoft excel driver 12.0 in your Data Sources(ODBC) in control panel

Wednesday, January 11, 2012

DTS not support in SQL Server 2008 R2

Limited SQL Server 2000 DTS Functionality on 64-bit Operating Systems
SQL Server 2008 does not include support for DTS in the following circumstances:
  • There is no 64-bit design-time or run-time support for DTS packages. On a 64-bit computer, DTS packages, and Integration Services packages that run DTS packages, can run only in 32-bit mode. For more information, see How to: Install Support for Data Transformation Services Packages.
  • There is also no 32-bit design-time or run-time support for DTS packages on Itanium-based operating systems. Therefore, you cannot create, view, modify, or run DTS packages on Itanium-based operating systems.
Supported SQL Server 2000 DTS Functionality
SQL Server 2008 includes support for the following DTS features:
  • The DTS runtime, the object model that it exposes, and the dtsrun.exe command prompt utility.
  • The Execute DTS 2000 Package task, for executing DTS packages within Integration Services packages.
  • The ActiveX Script task, for backward compatibility only.
  • The DTS Package Migration Wizard, for migrating DTS packages to the Integration Services package format.
  • The Upgrade Advisor rules for DTS packages, for identifying potential issues that may be encountered when migrating packages.
more details on http://msdn.microsoft.com/en-us/library/bb500440.aspx

Friday, December 23, 2011

Import Excel Data into Mssql using SQL Statement

you need to run one line per line, if you run all SQL together.
you will get below error message:

Incorrect syntax near 'sp_configure' 

Please Follow below Step 
Step 1sp_configure 'show advanced options', 1
Output Message: Configuration option 'show advanced options' changed from 0 to 1. Run the RECONFIGURE statement to install.

Step 2reconfigure
Output MessageCommand(s) completed successfully.

Step 3sp_configure 'Ad Hoc Distributed Queries', 1
Output MessageConfiguration option 'Ad Hoc Distributed Queries' changed from 1 to 1. Run the RECONFIGURE statement to install.

Step 4reconfigure
Output MessageCommand(s) completed successfully.

Step 5: Run your SQL to import Excel Files

Insert Excel Data into New Table (Create New Table)

SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:\Staffs.xls', 'SELECT * FROM [Sheet1$]')

Insert Excel Data into Existing Table
SELECT * INTO  myTableName FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:\Staffs.xls', 'SELECT * FROM [Sheet1$]')

SQL Code to import Excel Data into New Table in Database

sp_configure 'show advanced options', 1
sp_configure 'Ad Hoc Distributed Queries', 1

SELECT * INTO  myTableName FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:\Staffs.xls', 'SELECT * FROM [Sheet1$]')

SQL Code to import Excel Data into Existing Table in Database

sp_configure 'show advanced options', 1
sp_configure 'Ad Hoc Distributed Queries', 1

SELECT * INTO  myTableName FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:\Staffs.xls', 'SELECT * FROM [Sheet1$]')

Friday, September 30, 2011

Database owner is already a user in the database

Error : Msg 15110, Level 16, State 1, Procedure sp_changedbowner, Line 46
The proposed new database owner is already a user in the database

If you are getting above error message while changing the database owner. ‘DBuser’ cannot become the owner of the current database if it already has access/dbo access to the database through an existing alias or user security account within the database. To avoid this, drop the alias or ‘user’ within the current database first. here is the solution.

Use Database_Name;
sp_dropuser ‘DBUser’
sp_changedbowner ‘DBUser’

Back Up the Transaction Log When the Database Is Damaged

To create a backup of the currently active transaction log

  1. Execute the BACKUP LOG statement to back up the currently active transaction log, specifying:
    • The name of the database to which the transaction log to back up belongs.
    • The backup device where the transaction log backup will be written.
    • The NO_TRUNCATE clause.
      This clause allows the active part of the transaction log to be backed up even if the database is inaccessible, provided that the transaction log file is accessible and undamaged.
  2. Optionally, specify:
    • The INIT clause to overwrite the backup media, and write the backup as the first file on the backup media. If no existing media header exists, one is automatically written.
    • The SKIP and INIT clauses to overwrite the backup media, even if there are either backups on the backup media that have not yet expired, or the media name does not match the name on the backup media.
    • The FORMAT clause, when you are using media for the first time, to initialize the backup media and rewrite any existing media header.
      The INIT clause is not required if the FORMAT clause is specified.

This example backs up the currently active transaction log for the MyAdvWorks_FullRM database even though MyAdvWorks_FullRM has been damaged and is inaccessible. However, the transaction log is undamaged and accessible:

   TO MyAdvWorks_FullRM_log1

Thursday, September 29, 2011

10 reasons why go for SQL Server 2008

10.  Plug-in model for SSMS.   SSMS 2005 also had a plug-in model, but it was not published, so the few developers that braved that environment were flying blind.  Apparently for 2008, the plug-in model will be published and a thousand add-ins will bloom. 
9.  Inline variable assignment.  I often wondered why, as a language, SQL languishes behind the times.  I mean, it has barely any modern syntactic sugar.  Well, in this version, they are at least scratching the the tip of the iceberg. 
Instead of:
DECLARE @myVar int 
SET @myVar = 5

you can do it in one line:
DECLARE @myVar int = 5

8.  C like math syntax.  SET @i += 5.  Enough said.  They finally let a C# developer on the SQL team. 
7.  Auditing.  It's a 10 dollar word for storing changes to your data for later review, debugging or in response to regulatory laws.  It's a thankless and a mundane task and no one is ever excited by the prospect of writing triggers to handle it.  SQL Server 2008 introduces automatic auditing, so we can now check one thing off our to do list.
6.  Compression.  You may think that this feature is a waste of time, but it's not what it sounds like.  The release will offer row-level and page-level compression.  The compression mostly takes place on the metadata.  For instance, page compression will store common data for affected rows in a single place. 
The metadata storage for variable length fields is going to be completely crazy: they are pushing things into bits (instead of bytes).  For instance, length of the varchar will be stored in 3 bits. 
Anyway, I don't really care about space savings - storage is cheap.  What I do care about is that the feature promised (key word here "promises") to reduce I/O and RAM utilization, while increasing CPU utilization.  Every single performance problem I ever dealt with had to do with I/O overloading.  Will see how this plays out.  I am skeptical until I see some real world production benchmarks.
5.  Filtered Indexes.  This is another feature that sounds great - will have to see how it plays out.  Anyway, it allows you to create an index while specifying what rows are not to be in the index.  For example, index all rows where Status != null.  Theoretically, it'll get rid of all the dead weight in the index, allowing for faster queries. 
4.  Resource governor.  All I can say is FINALLY.  Sybase has had it since version 12 (that's last millennium, people).  Basically it allows the DBA to specify how much resources (e.g. CPU/RAM) each user is entitled to.  At the very least, it'll prevent people, with sparse SQL knowledge from shooting off a query with a Cartesian product and bringing down the box.
Actually Sybase is still ahead of MS on this feature.  Its ASE server allows you to prioritize one user over another - a feature that I found immensely useful.
3.  Plan freezing.  This is a solution to my personal pet peeve. Sometimes SQL Server decides to change its plan on you (in response to data changes, etc...).  If you've achieved your optimal query plan, now you can stick with it.  Yeah, I know, hints are evil, but there are situations when you want to take a hammer to SQL Server - well, this is the chill pill.
2.  Processing of delimited strings.   This is awesome and I could have used this feature...well, always.  Currently, we pass in delimited strings in the following manner:
exec sp_MySproc 'murphy,35;galen,31;samuels,27;colton,42'

Then the stored proc needs to parse the string into a usable form - a mindless task.
In 2008, Microsoft introduced Table Value Parameters (TVP). 
CREATE TYPE PeepsType AS TABLE (Name varchar(20), Age int) 
DECLARE @myPeeps PeepsType 
INSERT @myPeeps SELECT 'murphy', 35 
INSERT @myPeeps SELECT 'galen', 31 
INSERT @myPeeps SELECT 'samuels', 27 
INSERT @myPeeps SELECT 'colton', 42

exec sp_MySproc2 @myPeeps 

And the sproc would look like this:
CREATE PROCEDURE sp_MySproc2(@myPeeps PeepsType READONLY) ...

The advantage here is that you can treat the Table Type as a regular table, use it in joins, etc.  Say goodbye to all those string parsing routines.
1. Intellisense in the SQL Server Management Studio (SSMS).  This has been previously possible in SQL Server 2000 and 2005 with Intellisenseuse of 3rd party add-ins like SQL Prompt ($195).  But these tools are a horrible hack at best (e.g. they hook into the editor window and try to interpret what the application is doing).  
Built-in intellisense is huge - it means new people can easily learn the database schema as they go.