Translate

Monday 24 April 2017

MySQl : check existance of table in MySQL database by table name and database name

select table_name  from information_schema.tables
where  table_schema = 'databaseName' and table_name LIKE 'tableName'

MySQL : While delete record from table where clause doesn't contain primary key column ie AnyColumn

If I delete record from a table with where condition and in where clause the column is primary key then there is no error
ie
delete from  mydatabasename.tableName
where Id=33;commit;
 here there is no error .

where as  While the below case
If I delete record from a table with where condition and in where clause the column is not a  primary key then there is  error
ie
below example

delete from  mydatabasename.tableName
where date_format(record_date,'%Y/%m/%d')='2017/04/24';commit;

Error:
Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column To disable safe mode, toggle the option in Preferences -> SQL Editor and reconnect.

Solution:

set sql_safe_updates = 0;
delete from  mydatabasename.tableName
where date_format(record_date,'%Y/%m/%d')='2017/04/24';commit;
SET sql_safe_updates = 1;

Thursday 20 April 2017

sql : get day,month and year in a date

I have run this query ie today(20 April 2017) is  2017-04-20 14:42:33.093

SELECT getdate()--2017-04-20 14:42:33.093
SELECT datepart(day, getdate())--20   -- Day
SELECT datepart(Month, getdate())--4 --- Month
SELECT datepart(YEAR, getdate())--2017--Year

Tuesday 18 April 2017

MySQL create table syntax

CREATE TABLE `tableNmae` (
  `SlNo` int(11) NOT NULL AUTO_INCREMENT,
  `Name` text,
  `SysDate` datetime DEFAULT NULL,
  `Estatus` text,
  `details` text,
  PRIMARY KEY (`SlNo`)
);commit;

download file from SFTP using WinSCP with batch file(SSIS using process task )

For download
-------------------
option batch on
 option confirm off
 open sftp://UserName:Password@SFTPName:portnumber/ -hostkey="winscphostKey"
 get  SFTPFILEnamewithextension
 close
 exit


For remove file from SFTP
-------------------
option batch on
 option confirm off
 open sftp://UserName:Password@SFTPName:portnumber/ -hostkey="winscphostKey"
 rm  SFTPFILEnamewithextension
 close
 exit



For rename  file from SFTP
-------------------
option batch on
 option confirm off
 open sftp://UserName:Password@SFTPName:portnumber/ -hostkey="winscphostKey"
 mv  oldNamefromSFTPfile userNewname
 close
 exit

MySQL get database table create table in query format

 SHOW CREATE TABLE `Yourtablename`;COMMIT;
example :
I have a table in MySQL ie FredtoMySQL_execution_log and I want to see the definition ie below code

 SHOW CREATE TABLE `FredtoMySQL_execution_log`;COMMIT;

MySQL rename table

 RENAME TABLE ssis_execution_log TO SQLtoMYSQL_execution_log;COMMIT;

Thursday 13 April 2017

what is .NET Framework ?

.NET Framework is set of tools, libraries, languages to build Desktop, Console , Web , Mobile ,IOS  applications and run time required to run those applications.

The full Form of .NET is Network Enabled Technologies.
 Or Distributed oriented Technologies