谁说不能?
===================================
<HTML>
<BODY>
<script type="text/javascript">  
// 说明:获取页面上选中的文字 
function getSelectedText() {   
if(document.selection.type!="Text"){
return;
}
if (window.getSelection) {         
// This technique is the most likely to be standardized.         
// getSelection() returns a Selection object, which we do not document.         
return window.getSelection().toString();     
}else if (document.getSelection) {         
// This is an older, simpler technique that returns a string         
return document.getSelection();     
}else if (document.selection) {      
// This is the IE-specific technique.         
// We do not document the IE selection property or TextRange objects.      
return document.selection.createRange().text; 
}
}  
</script> 
SQL查询
<textarea id="txtSql" cols="40" rows="10">select * from book where bid=1;
GO;
</textarea>
<input name="btnRun" type="button" id="btnRun"  onClick="alert(getSelectedText());" value="查询">
</BODY>
</HTML>======================================
类似这样的问题,有时你可以到ASP.Net板块上问。那里高手较多。