jquery scroll trigger


$(windows).scroll(function(){

if($(window).scrollTop()==$(document).height()-$(window).height()){

doSomthing();

//When scroll bar at the bottom of the window doSomthing method will be triggered

}

});


You can use this script for scroll pagination.

Advertisements

Textarea enter submit

<html lang="eng">
	<head>
		<title> Index Page </title>
		<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
		<script type"text/javascript">
		$(function(){
		$('#txtMessage').focus();
		
		$('#txtMessage').keydown(function(event){
		
		if(event.keyCode==13 && event.shiftKey) return;
		
		if(event.keyCode==13){
		var messageBody=$('#txtMessage').val();
		$('<p/>').html(messageBody).appendTo($('#content'));
		$('#txtMessage').val('').focus();
		event.preventDefault();
		}
		
		});
		
		});
		</script>
	</head>
	<body>

	<hr/>
	<hr/>
	
	<textarea id="txtMessage" col="50" rows="5" placeholder="Enter your message"></textarea>
	
	<div id="content" style="white-space:pre"></div>

	</body>
</html>

This script shows textarea enter submit , shift+enter is new line key also after submit shows place holder message again.

Shrink sql database transaction log file

--Database Name
USE Database_Name;
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE Database_Name
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (Database_Name_Log, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE Database_Name
SET RECOVERY FULL;
GO

When your sql database transaction log file is too big than shrink it . It will take about 30 second. You can run this script any time you want.

Sql row number usage

USE AdventureWorks2012;
GO
WITH OrderedOrders AS
(
    SELECT SalesOrderID, OrderDate,
    ROW_NUMBER() OVER (ORDER BY OrderDate) AS RowNumber
    FROM Sales.SalesOrderHeader 
) 
SELECT SalesOrderID, OrderDate, RowNumber  
FROM OrderedOrders 
WHERE RowNumber BETWEEN 50 AND 60;

PS: When you do not have increase identity number . You can use ms sql row number feature.

Query from different sql server


EXEC sp_configure 'show advanced options', 1
RECONFIGURE
GO
EXEC sp_configure 'ad hoc distributed queries', 1
RECONFIGURE
GO

SELECT  *
FROM OPENDATASOURCE('SQLNCLI',
 ' Data Source=******;User ID=******;Password=****** ')
 .[databseName].[dbo].[tableName]
GO

PS: First ‘show advanced options’ and ‘Ad Hoc Distributed Queries’ turn on and then use sql OPENDATASOURCE command first parameter provider and second parameter is connection string that you want to connect.

Sql server remote connection

# Check right click sql server instance Properties>Connections Allow remote connection to this server .

# Open sql server configuration manager > SqlServer Network Configuration > Protocols For Sql Server  then enable TCP/IP and TCP/IP >Ip Address Tcp port must be 1433.

# Go to windows firewall >  Advanced Settings  > Inbounds Rules and add new rule  add tcp port 1433 then enable rule.