Tuesday, March 27, 2018

parse float with Comma Decimal Values

javascript's parseFloat doesn't take a locale parameter. So you will have to replace comma(,), dollar sign($) with empty

Example :
 Full Cost  Value : $1,500.00

convert the commas to Normal value(decimal value).

var fullcost = parseFloat($("#fullcost").text().replace('$', '').replace(',', '').replace(',', '.')); //1500.00

fullcost =parseFloat(1500.00)

Result value : 1500.00



The parseFloat() function parses a string and returns a floating point number.

This function determines if the first character in the specified string is a number. If it is, it parses the string until it reaches the end of the number, and returns the number as a number, not as a string.

Note: Only the first number in the string is returned!

Note: Leading and trailing spaces are allowed.

Note: If the first character cannot be converted to a number, parseFloat() returns NaN.
   

Wednesday, March 21, 2018

Common Table Expressions

Common Table Expressions are also called CTEs. This feature was introduced with SQL Server 2005. The CTE is preferred to use as an alternative to a Subquery/View.

Sub-queries

A sub-query is a query within a query. It is also called an inner query or a nested query. A sub-query is usually added in a where clause of the SQL statement.

Example
Select Name,Age, employeeID   
From table1   
Where employeeID in   

   Select employeeID from table2 where salary >=7500 /******Sub Query******/ 
)

use a CTE

With aliastablename (column1) 
 
AS 
 
(Query)

example
With table1CTE(EmployeeID) 
 
AS   
(Select employeeID from table1 where salary >=7500)

Advantages
CTE improves the code readability.
CTE provides recursive programming.
CTE makes code maintainability easier.
Though it provides similar functionality as a view, it will not store the definition in metadata.

Monday, March 12, 2018

Find all tables containing column with specified name


select * from INFORMATION_SCHEMA.COLUMNS
where COLUMN_NAME like '%TableColumnName%'
order by TABLE_NAME


Select * from  INFORMATION_SCHEMA.COLUMNS
where COLUMN_NAME LIKE '%TableColumnName%'

How can I list all foreign keys referencing a given table in SQL Server?

EXEC sp_fkeys 'TableName'

Change default Port on Next.js app

 If any other app or process is running on port 3000 , you will get this error in your terminal Port 3000 is already in use. error Command f...