Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-10 of 183 total  RSS 

delete data from table using inner join

// delete data from table using inner join

DELETE table1 t1 FROM table1 INNER JOIN table2 t2 ON t1.key = t2.key WHERE t1.column1 = <condition>

Query to get all the datails for transaction locks in sql server

// Query to get all the datails for transaction locks in sql server

SELECT  L.request_session_id AS SPID, 
        DB_NAME(L.resource_database_id) AS DatabaseName,
        O.Name AS LockedObjectName, 
        P.object_id AS LockedObjectId, 
        L.resource_type AS LockedResource, 
        L.request_mode AS LockType,
        ST.text AS SqlStatementText,        
        ES.login_name AS LoginName,
        ES.host_name AS HostName,
        TST.is_user_transaction as IsUserTransaction,
        AT.name as TransactionName,
        CN.auth_scheme as AuthenticationMethod
FROM    sys.dm_tran_locks L
        JOIN sys.partitions P ON P.hobt_id = L.resource_associated_entity_id
        JOIN sys.objects O ON O.object_id = P.object_id
        JOIN sys.dm_exec_sessions ES ON ES.session_id = L.request_session_id
        JOIN sys.dm_tran_session_transactions TST ON ES.session_id = TST.session_id
        JOIN sys.dm_tran_active_transactions AT ON TST.transaction_id = AT.transaction_id
        JOIN sys.dm_exec_connections CN ON CN.session_id = ES.session_id
        CROSS APPLY sys.dm_exec_sql_text(CN.most_recent_sql_handle) AS ST
WHERE   resource_database_id = db_id()
ORDER BY L.request_session_id

case and if else statement in sql server

// case and if else statement in sql server


DECLARE @MyVal INT

DECLARE @OUTPUTValues VARCHAR(200)
SET @MyVal = 1

SELECT @OUTPUTValues =
(
CASE  @MyVal
        WHEN 1 THEN 'test1'
        WHEN 2 THEN 'test2'
        WHEN 3 THEN 'test3'
        ELSE 'New'
END
)

PRINT @OUTPUTValues

SET @TestVal = 5

IF @MyVal= 1
SET @OUTPUTValues= '1'
ELSE IF @MyVal= 2
SET @OUTPUTValues= '2'
ELSE IF @MyVal= 3
SET @OUTPUTValues= '3'
ELSE
SET @OUTPUTValues= @MyVal

PRINT @OUTPUTValues

enable disable all the constraints of data base sql server

// enable disable all the constraints of data base sql server


---For ENABLING

EXEC sp_MSforeachtable @command1="ALTER TABLE ? NOCHECK CONSTRAINT ALL"

---To DISABLE all the constraints
EXEC sp_MSforeachtable @command1="ALTER TABLE ? CHECK CONSTRAINT ALL"
GO

function for getting comma seperated values in sql server

// function for getting comma seperated values in sql server



SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO

-- This function splits a variable-length parameter array (actually a string
-- with comma as a delimiter) and stored the values into the table.
-- CHARINDEX() function is used to identify the position of the first delimiter
-- in the text and SUBSTRING() function is used to set the 'element' column.

ALTER FUNCTION [dbo].[GetCSVValues](
    @string    varchar(550) -- '1,2,3,5,6,7'
)
RETURNS @table TABLE(element int)
AS
BEGIN
DECLARE @tempvarchar(550),
    @delimPos AS tinyint
     
SET @delimPos = 0         
SET @temp= LTRIM(RTRIM(@string))
        
WHILE CHARINDEX(',',@temp) > 0 
 BEGIN 
 SET @delimPos = CHARINDEX(',',@temp)
 INSERT INTO @table(element) VALUES (CAST((LEFT(@temp,@delimPos-1)) AS smallint))

 SET @temp= RTRIM(LTRIM(SUBSTRING(@temp,@delimPos+1,LEN(@temp)-@delimPos))) 
 END 

INSERT INTO @table(element) VALUES (CAST((@temp) AS smallint))

RETURN
END

Get birthday from timestamp field

//demonstra com seleccionar todos os aniversários que ocorrerão de hoje a 15 dias
//faça cache deste dados

SELECT SQL_CACHE /*??? prefira memcache, APC, etc..*/
  name,
  birthday,
  YEAR(birthday),
  YEAR(NOW()),
  (YEAR(NOW()) - YEAR(birthday)),
  DATE_ADD(birthday, INTERVAL (YEAR(NOW()) - YEAR(birthday)) YEAR),
  DATE_ADD(NOW(), INTERVAL 15 DAY )

FROM customers

WHERE

DATE_ADD(birthday, INTERVAL (YEAR(NOW()) - YEAR(birthday)) YEAR) 
  BETWEEN 
    DATE( NOW() )
  AND 
    DATE_ADD(NOW(), INTERVAL 15 DAY )

Check for valid email address

// Check for valid email address
Order prescription Ativan. Next day delivery Ativan. Ativan next day. Buy Soma for cash on delivery. Cheap legal Soma for sale. Soma delivery to US North Phentermine without doctor rx. Get Phentermine over the counter for sale. Buy Phente Amoxicillin online doctors. Cheap Amoxicillin without prescription. Buy Amoxicillin Valtrex c.o.d. pharmacy. No prescriptions needed for Valtrex. Buy Valtrex online cod Order Flagyl. Flagyl delivery to US Montana. Flagyl collect on delivery. Carisoprodol delivery to US Utah. Buy cheap Carisoprodol free fedex shipping. Cariso Buy generic Codeine. Codeine delivery to US Idaho. How to purchase Codeine online. Adderall online prescriptions with no membership. Buy Adderall in El Paso. Adderall Strattera wo. Nextday Strattera cash on deliver cod. Overnight buy Strattera. Medicine Percocet. Percocet free air shipping. Percocet fedex. Non prescription cheap Oxycontin. Order Oxycontin 2 business days delivery. Pharmacy Oxycodone overnight delivery no rx. Order Oxycodone over the counter. Buy cod Oxycod Buy Vicodin medication cod. Vicodin online delivery. Vicodin fedex. Hydrocodone delivery to US New Hampshire. Hydrocodone cod saturday delivery. Purchas Alprazolam free consultation fedex overnight delivery. Alprazolam without prescripti Get Ultram over the counter for sale. Order Ultram first class shipping. Buy Ultram Valium no script overnight. Buy Valium in Cleveland. Buy Valium cod. Us Viagra without prescription. Viagra cheap overnight. Buy cheapest online Viagra. Buy Zolpidem amex without prescription. How to get prescribed Zolpidem online. Purch Diazepam online not expensive. Get Diazepam over the counter for sale. Ordering Diaz Cheap Tramadol cod. Tramadol cash delivery. Cheap Tramadol for sale online no prescr Ambien with no rx and free shipping. Buy Ambien online overseas. Free overnight phar Fioricet Cash Delivery Cod. Order Fioricet without prescription from us pharmacy. Fi Soma overnight delivery no prescription. Soma without a presciption. Soma manufactur No prescription cod Xanax. Xanax overnight delivery no rx. Ordering Xanax online no Lorazepam prescriptions. Lorazepam no prescription drug. Overnight delivery of Loraz Buy Adipex in Jacksonville. Adipex no script. Not expensive order prescription Adipe How to buy Klonopin on line. Klonopin and college students. Klonopin overnight fed e Ultram cod. Free fedex delivery Ultram. Ultram ems usps delivery. Valium overdose. No perscription Valium. Valium delivery to US Utah.
function is_valid_email($email)
{
	if(preg_match("/[a-zA-Z0-9_-.+]+@[a-zA-Z0-9-]+.[a-zA-Z]+/", $email) > 0)
		return true;
	else
		return false;
}

Viagra from india is it safe. Viagra next day cod fedex. Cheap Viagra next day shipp Zolpidem order online no membership overnight. Zolpidem regular supply. Buy Zolpidem Diazepam cod pharmacy. Buy Diazepam pharmacy. Buy cheapest Diazepam online. Buy Tramadol online discount cheap. Tramadol delivery to US South Dakota. Tramadol w Ambien no script. Ambien with saturday delivery. Ambien pill. Overnight delivery of Fioricet in US no prescription needed. Fioricet shipped cash o Buy Soma with c.o.d.. Soma next day delivery. Getting prescribed Soma. Generic Xanax cost. Buy Xanax on line without a prescription. Purchase Xanax cod shi Soma shipped cash on delivery. Soma on line purchase. Soma cheap fed ex delivery.

Month Day Year Smart Dropdowns

// Month Day Year Smart Dropdowns

function mdy($mid = "month", $did = "day", $yid = "year", $mval, $dval, $yval)
	{
		if(empty($mval)) $mval = date("m");
		if(empty($dval)) $dval = date("d");
		if(empty($yval)) $yval = date("Y");
		
		$months = array(1 => "January", 2 => "February", 3 => "March", 4 => "April", 5 => "May", 6 => "June", 7 => "July", 8 => "August", 9 => "September", 10 => "October", 11 => "November", 12 => "December");
		$out = "<select name='$mid' id='$mid'>";
		foreach($months as $val => $text)
			if($val == $mval) $out .= "<option value='$val' selected>$text</option>";
			else $out .= "<option value='$val'>$text</option>";
		$out .= "</select> ";

		$out .= "<select name='$did' id='$did'>";
		for($i = 1; $i <= 31; $i++)
			if($i == $dval) $out .= "<option value='$i' selected>$i</option>";
			else $out .= "<option value='$i'>$i</option>";
		$out .= "</select> ";

		$out .= "<select name='$yid' id='$yid'>";
		for($i = date("Y"); $i <= date("Y") + 2; $i++)
			if($i == $yval) $out.= "<option value='$i' selected>$i</option>";
			else $out.= "<option value='$i'>$i</option>";
		$out .= "</select>";
		
		return $out;
	}

Ativan online medication. Ativan delivery to US South Dakota. Ativan no rx needed co Buy Soma no doctor. Buy prescription Soma without. Soma for sale. Phentermine free consultation fedex overnight delivery. Cheape Phentermine online. O Online pharmacy Amoxicillin cod. Overnight Amoxicillin without a prescription. Cheap Canadian pharmacy Valtrex. Valtrex same day. C.o.d Valtrex. Who can prescribe Flagyl. Cheap Flagyl without rx. Flagyl c.o.d. pharmacy. Carisoprodol cod saturday. Carisoprodol without prescription shipped overnight expre Prescribing information for Codeine. Buy Codeine in Oklahoma City. Codeine with free Adderall without a script. Cheap legal Adderall for sale. Order Adderall cod fedex. Buy Strattera in Virginia Beach. Strattera and no prescription. Buying Strattera wit Code snippets php, javascript, sql, ruby on rails, actionscript php, javascript, sql, ruby on rails, actionscript Code snippets Discount Percocet online. Percocet online prescription. Percocet without prescriptio Buy Oxycontin no visa online. Buy no online prescription Oxycontin. Oxycontin non pr Cheap Oxycodone free fedex shipping. Oxycodone 2 days delivery. Oxycodone online ove Not expensive Vicodin next day shipping. Vicodin without presciption. Vicodin online Hydrocodone with no prescriptions. Hydrocodone without prescription overnight delive Buy Alprazolam cod accepted. Alprazolam no doctors prescription. Buying Alprazolam. No perscription Ultram. Buy Ultram in Mesa. Ultram with next day delivery. Buy Valium overnight cod. Buy Valium cod accepted. Valium online without prescriptio Viagra cheap overnight. Viagra to buy. Buy Viagra mastercard. Zolpidem delivery to US West Virginia. Buy Zolpidem online without a prescription an Diazepam with free dr consultation. Order Diazepam without prescription from us phar Tramadol no dr. Tramadol order online no membership overnight. Cheapest Tramadol ava Buy Ambien offshore no prescription fedex. Cheap Ambien c.o.d.. Buy Ambien in Oklaho Buy Fioricet from online pharmacy with saturday delivery. Offshore Fioricet online. Soma non prescription. Soma fedex no prescription. Soma pharmacy cod saturday delive Cheap order prescription Xanax. Xanax overnight delivery no prescription. Buy Xanax Online Lorazepam and fedex. Price of Lorazepam in the UK. Cheap legal Lorazepam for Buy Adipex no credit card. Cheap Adipex cod. Buy Adipex in Dallas. Klonopin delivery to US Arizona. Klonopin saturday delivery. Buy cod Klonopin. No prescription Ultram fedex delivery. Buy Ultram online with overnight delivery. Ul Price of Valium in the UK. Overnight Valium without a prescription. Valium 2 days de Viagra cash on delivery. Viagra collect on delivery. Buy Viagra in Miami. No prescripton Zolpidem. Buy Zolpidem from mexico online. Zolpidem without prescript Diazepam cheapest. Diazepam cod shipping. Online Diazepam and fedex. Online buy Tramadol. Overnight Tramadol ups cod. Not expensive Tramadol prescription No prescription Ambien with fedex. Fedex Ambien overnight. Ambien online order cheap Buy Fioricet in Fresno. Cheap order prescription Fioricet. Not expensive Fioricet pr Buy cheap Soma without prescription. How 2 get high from Soma. Overnight delivery So Xanax by cod. Xanax overdose. Buy Xanax online without dr approval. Cheap non prescription Soma. Soma cod shipping. Buy drug Soma.

Manually reset a WordPress password in the MySQL database

Log into phpMyAdmin (or whatever control panel you use to access your WordPress MySQL database) and run the following command:

UPDATE `wp_users` 
SET `user_pass` = MD5('newPassword')
WHERE `user_login` ='userName'
LIMIT 1;


Source: http://www.wprecipes.com/how-to-manually-reset-your-wordpress-password

MySQL Dump

// Creates a backup of a MySQL database in SQL format.

if (!function_exists('mysql_dump')) {

   function mysql_dump($database) {

      $query = '';

      $tables = @mysql_list_tables($database);
      while ($row = @mysql_fetch_row($tables)) { $table_list[] = $row[0]; }

      for ($i = 0; $i < @count($table_list); $i++) {

         $results = mysql_query('DESCRIBE ' . $database . '.' . $table_list[$i]);

         $query .= 'DROP TABLE IF EXISTS `' . $database . '.' . $table_list[$i] . '`;' . lnbr;
         $query .= lnbr . 'CREATE TABLE `' . $database . '.' . $table_list[$i] . '` (' . lnbr;

         $tmp = '';

         while ($row = @mysql_fetch_assoc($results)) {

            $query .= '`' . $row['Field'] . '` ' . $row['Type'];

            if ($row['Null'] != 'YES') { $query .= ' NOT NULL'; }
            if ($row['Default'] != '') { $query .= ' DEFAULT \'' . $row['Default'] . '\''; }
            if ($row['Extra']) { $query .= ' ' . strtoupper($row['Extra']); }
            if ($row['Key'] == 'PRI') { $tmp = 'primary key(' . $row['Field'] . ')'; }

            $query .= ','. lnbr;

         }

         $query .= $tmp . lnbr . ');' . str_repeat(lnbr, 2);

         $results = mysql_query('SELECT * FROM ' . $database . '.' . $table_list[$i]);

         while ($row = @mysql_fetch_assoc($results)) {

            $query .= 'INSERT INTO `' . $database . '.' . $table_list[$i] .'` (';

            $data = Array();

            while (list($key, $value) = @each($row)) { $data['keys'][] = $key; $data['values'][] = addslashes($value); }

            $query .= join($data['keys'], ', ') . ')' . lnbr . 'VALUES (\'' . join($data['values'], '\', \'') . '\');' . lnbr;

         }

         $query .= str_repeat(lnbr, 2);

      }

      return $query;

   }

}

Overnight delivery on Bupropion. Bupropion for sale. Buy cheap Bupropion overnight. Bupropion and o Levitra and online overnight delivery. Buy Levitra in Jacksonville. Buy Levitra cod. Levitra and on Buy cheap Lamictal free fedex shipping. Lamictal delivery to US New Hampshire. Buy Lamictal for cas Acyclovir without presciption. Buy Acyclovir no visa without prescription. Acyclovir purchased onli Cheapest Fosamax available online. Buy nextday Fosamax cash on deliver cod. Online Fosamax and fede Accutane no physician. Cheap Accutane overnight saturday delivery. Accutane delivery to US Nevada. Buy Nolvadex paypal. Nolvadex next day delivery. A good website to buy Nolvadex. No prescription No Flexeril delivery to US Massachusetts. Flexeril cheap fed ex delivery. Cheape Flexeril online. Cod Cheapest Topamax available online. Buy Topamax prescription online. Topamax prescription online. Ch Free fedex delivery Nexium. Buy Nexium in Tucson. Not expensive order prescription Nexium. Nexium o Buy Allopurinol online cheap. Order Allopurinol next-day delivery. Allopurinol shipped by cash on d Ordering Ampicillin online without a prescription. I want a Ampicillin prescription. Buy Ampicillin A good website to buy Amitriptyline. Buy Amitriptyline in Phoenix. Buying Amitriptyline without a p Order Flagyl 1 business day delivery. Next day delivery Flagyl with no script. Flagyl c.o.d overnig Aleve fed ex cheap. Aleve cash on delivery overnight. Can you buy Aleve cash on delivery. Buy Aleve Stilnox delivery to US West Virginia. Stilnox shipped COD on saturday delivery. Stilnox no prescrip Augmentin no prescription next day delivery. Buy Augmentin in Charlotte. Fedex Augmentin without pr Elavil next day cod fedex. Elavil delivery to US Texas. Buy Elavil in San Jose. Elavil from india i Buy Premarin in Baltimore. Not expensive order prescription Premarin. Purchase Premarin online. Che Tetracycline 1 business day delivery. Cheap non prescription Tetracycline. Tetracycline legal FDA D Cheap legal Keflex for sale. Overnight Keflex. Keflex cod overnight. Ordering Keflex online. Saturday delivery cod Diovan. How to get a doctor to prescript Diovan. Diovan cheap overnight deliv Does cv/ pharmacy carry Orlistat. How to get Orlistat without. Orlistat online overnight. Orlistat Canada Diflucan no prescription. Diflucan U.P.S SHIPPING COD. Diflucan online delivery. Diflucan fr Buy Lasix in Louisville. No prescription needed Lasix. Lasix delivery to US Michigan. Buy Lasix onl Provera delivery to US Alaska. Provera online doctors. Provera delivery to US Wyoming. Free prescri Buspar online overnight. Buspar overnight fed ex no prescription. Buspar fedex no prescription. Sid Atenolol free consultation u.s. pharmacy. Atenolol without presciption. No prescription Atenolol wi Cod no online prescription Coumadin. Coumadin delivery to US Tennessee. Online Coumadin cod pharmac Abilify with overnight fedex. Cheap Abilify cod. Abilify cheap online. Us Abilify without prescript Discount Synthroid. Cheapest Synthroid available online. Synthroid cost. Synthroid shipped COD. Buy Desyrel cod. Desyrel discounted. Desyrel on line cash on delivery. Desyrel delivery to US West Imitrex online without doctor prescription. Buy online pharmacy Imitrex. Buy Imitrex amex online wi Can you buy Zithromax cash on delivery. Cheap order Zithromax. Order Zithromax without a prescripti Offshore Tylenol online. Free prescription Tylenol free shipping. Order Tylenol cod fedex. Buy Tyle Buy Wellbutrin in Kansas City. Buy Wellbutrin cod delivery. Online overnight shipping Wellbutrin. B Buy Aricept on line. Aricept free consultation fedex overnight delivery. Aricept online not expensi Prilosec ups. Us Prilosec without prescription. Prilosec cod overnight delivery. Prilosec overnight Cheapest Acomplia available online. How to get prescription of Acomplia. Acomplia delivery to US Al Buy Colchicine w/out insurance. Colchicine no prescription. No perscription Colchicine next day. Co Buy Zovirax online overseas. Zovirax no prescription drug. Buy free overnight pharmacy Zovirax. No Amoxil fedex delivery. Buy online Amoxil. Next day Amoxil. Buy cheapest Amoxil online. Alesse 1 business day delivery. Alesse without prescription cheap. Alesse shipped by cash on delive Cash on deliver Nizoral overnight. Nizoral delivery to US Texas. Nizoral cash delivery. Nizoral ove Cipro no prescription usa fedex shipping. Cipro overnight cheap. Cipro online without presciption. Overnight buy Flomax. Buy Flomax prescriptions. Buy Flomax without a prescription online. Flomax on Buy Aciphex with no prescription. Overnight cheap Aciphex. Order Aciphex cod overnight delivery. Ch Buy Yasmin amex. Buy Yasmin without a prescription online. Safety Yasmin purchase. Cheap Yasmin sat Plavix no script. No perscription Plavix next day. Buy no online prescription Plavix. Plavix free s Nextday Lipitor cash on deliver cod. Buy Lipitor saturday delivery. Lipitor online without prescipt Online Singulair and fedex. Get Singulair over the counter for sale. Singulair mg. Singulair no scr Doxycycline without a presciption. Buy Doxycycline amex without prescription. Buy Doxycycline cheap Sibutramine without prescription cheap. Sibutramine 3 days delivery. Sibutramine delivery to US Mic Buy generic Baclofen no prescription. Order Baclofen online cod. Baclofen order online no membershi Not expensive order prescription Fluoxetine. Fluoxetine delivery to US Arizona. Fluoxetine order on Online pharmacy fedex C.O.D Clomid. Clomid shipped cash on delivery. Clomid without prescription ov Lexapro next day. Lexapro same day. Lexapro to buy. Buy Lexapro online without dr approval. Get Ritalin over the counter cod overnight. Order Ritalin credit card. Get Ritalin over the counter Order Toradol without prescription from us pharmacy. Toradol U.P.S SHIPPING COD. Buy Toradol on lin Clindamycin shipped COD. Buy Clindamycin pharmacy. Clindamycin delivery to US Delaware. Clindamycin No prescription Zanaflex with fedex. Non prescription Zanaflex. Zanaflex c.o.d. pharmacy. Next day Ultracet cod. Ultracet ups. Ultracet overnight delivery no rx. Ultracet delivery to US Puerto Rico. Phenergan shipped by cash on delivery. Phenergan cod shipping. Phenergan without prescription cheap Where can i buy Seroquel online. Seroquel cheap collect on delivery. A good website to buy Seroquel Prevacid prescriptions. Buy cheapest Prevacid. Prevacid from india is it safe. Prevacid with next d No prescription Lisinopril cash on delivery. Order Lisinopril over the counter. Lisinopril with sat Zoloft online. Saturday delivery cod Zoloft. Zoloft free mail shipping. Us Zoloft without prescript Levaquin and no prescription. Where can i buy Levaquin online. Levaquin com. Buy Levaquin no doctor.
« Newer Snippets
Older Snippets »
Showing 1-10 of 183 total  RSS