Skip to content

Instantly share code, notes, and snippets.

@nisar1
nisar1 / Cast
Created March 8, 2014 07:41
According to the MySQL docs you can only cast to:
According to the MySQL docs you can only cast to:
BINARY[(N)]
CHAR[(N)]
DATE
DATETIME
DECIMAL[(M[,D])]
SIGNED
[INTEGER]
TIME
@nisar1
nisar1 / defination.sql
Last active August 29, 2015 13:57
defination of database objects.
-- Lists sp,tbl,fn in a dbz
--show procedure
SHOW PROCEDURE STATUS WHERE Db = DATABASE() AND TYPE = 'PROCEDURE';
SHOW FUNCTION STATUS WHERE Db = DATABASE() ;
select name from mysql.proc where db = database();
--list keys
select *
from INFORMATION_SCHEMA.TABLE_CONSTRAINTS
@nisar1
nisar1 / toggle
Created March 13, 2014 06:33
toggle function in jQuery
jQuery(document).ready(function () {
jQuery.fn.clickToggle = function (func1, func2) {
var funcs = [func1, func2];
this.data('toggleclicked', 0);
this.click(function () {
var data = jQuery(this).data();
var tc = data.toggleclicked;
jQuery.proxy(funcs[tc], this)();
data.toggleclicked = (tc + 1) % 2;
});
@nisar1
nisar1 / toggle2
Last active August 29, 2015 13:57
toggle 2 function in jQuery
jQuery('.barmenu').click(function () {
var lwidth = '260px';
if (!jQuery(this).hasClass('open')) {
jQuery('.rightpanel, .headerinner, .topbar').css({ marginLeft: lwidth }, 'fast');
jQuery('.leftpanel').css({ marginLeft: 0 }, 'fast');
jQuery(this).addClass('open');
} else {
jQuery('.rightpanel, .headerinner, .topbar').css({ marginLeft: 0 }, 'fast');
jQuery('.leftpanel').css({ marginLeft: '-' + lwidth }, 'fast');
@nisar1
nisar1 / database design
Created March 15, 2014 10:09
database design notes
Part I: Relational Database Design
The Relational Database
Design Objectives
Terminology
Part II: The Design Process
Conceptual Overview
Starting the Process
Analyzing the Current Database
Establishing Table Structures
Keys
@nisar1
nisar1 / encript all sp mssql
Created March 15, 2014 13:26
encript all sp
CREATE TABLE #backup
(
id BIGINT IDENTITY(1, 1),
sptext NVARCHAR(MAX) NOT NULL,
spname NVARCHAR(100) NOT NULL,
encrypttext NVARCHAR(MAX) NULL,
encryptstatus BIT NOT NULL
DEFAULT ( 0 )
)
DECLARE @sptexttable TABLE
@nisar1
nisar1 / search table mssql.sql
Last active August 29, 2015 13:57
search string in tables
CREATE PROCEDURE USP_SearchTables
@Tablenames VARCHAR(500)
,@SearchStr NVARCHAR(60)
,@GenerateSQLOnly Bit = 0
AS
/*
Parameters and usage
@nisar1
nisar1 / auto increment mssql.sql
Last active August 29, 2015 13:57
auto increment value
SELECT AUTO_INCREMENT FROM information_schema.tables WHERE table_name = 'item_tbl' AND table_schema = 'db_sanitary2'
@nisar1
nisar1 / increse import size in mysql
Created March 15, 2014 13:32
increse import size in mysql
Try these different settings in C:\wamp\bin\apache\apache2.2.8\bin\php.ini
Find:
post_max_size = 8M
upload_max_filesize = 2M
max_execution_time = 30
max_input_time = 60
memory_limit = 8M
Change to:
@nisar1
nisar1 / transaction in sp.sql
Last active August 29, 2015 13:57
transaction in sp mysql
DELIMITER $$
CREATE PROCEDURE `transaction_sp` ()
BEGIN
DECLARE exit handler for sqlexception
BEGIN
-- ERROR
ROLLBACK;