方法一:
<%@ Page Language="C#" CodeFile="Default.aspx.cs" Inherits="Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server"></head>
<body>
<form id="form1" runat="server">
<asp:ListView ID="ListView1"
runat="server"
ItemPlaceholderID="MyLayout$itemPlaceholder"
OnLayoutCreated="ListView1_LayoutCreated">
</asp:ListView>
<asp:Button ID="Button1" runat="server" Text="I Do Postbacks" />
</form>
</body>
</html>
using System;
using System.Linq;
using System.Web.UI;
using System.Xml.Linq;
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
XDocument xdoc = XDocument.Load(Server.MapPath("~/XmlFile.xml"));
var query = from x in xdoc.Descendants("book")
select new { id = (string)x.Attribute("id") };
ListView1.DataSource = query;
ListView1.DataBind();
}
protected void ListView1_LayoutCreated(object sender, EventArgs e)
{
ListView1.LayoutTemplate = LoadTemplate("WebUserControl.ascx");
ListView1.ItemTemplate = LoadTemplate("WebUserControl2.ascx");
Control newLayoutContainer = new Control();
ListView1.LayoutTemplate.InstantiateIn(newLayoutContainer);
var userControl = newLayoutContainer.Controls[0];
userControl.ID = "MyLayout";
ListView1.Controls.Add(newLayoutContainer);
}
}
方法二:
I received an email question recently from a customer asking how they could dynamically load the LayoutTemplate for a ListView from a UserControl. I banged my head on this one for a while and eventually mailed our internal ASP.NET alias asking if someone could help. Fortunately David Fowler could. Hats off to him - the code below is his solution.
Let's start with a basic ListView page that we want to convert to load the LayoutTemplate from a UserControl. Something like this will do:
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server"></head>
<body>
<form id="form1" runat="server">
<asp:ListView ID="ListView1" runat="server"
DataSourceID="XmlDataSource1">
<LayoutTemplate>
<ul>
<asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
</ul>
</LayoutTemplate>
<ItemTemplate>
<li><%# Eval("id") %></li>
</ItemTemplate>
</asp:ListView>
<asp:XmlDataSource ID="XmlDataSource1" runat="server"
XPath="/catalog/book"
DataFile="~/XMLFile.xml">
</asp:XmlDataSource>
</form>
</body>
</html>
We have an XmlDataSource (in my case pointing to the MSDN sample XML file) and I'm binding the book ids to list items in an unordered list using a ListView control. Pretty straightforward so far.
Imagine I refactored this a little to use a UserControl for the LayoutTemplate
<%@ Control Language="C#" %>
<ul>
<asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
</ul>and one for the ItemTemplate
<%@ Control Language="C#" %>
<li>
<%# Eval("id") %>
</li>That means I could replace my original aspx file with one that looks like this
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
</head>
<body>
<form id="form1" runat="server">
<asp:ListView ID="ListView1" runat="server"
ItemPlaceholderID="MyLayout$itemPlaceholder"
DataSourceID="XmlDataSource1">
</asp:ListView>
<asp:XmlDataSource ID="XmlDataSource1" runat="server"
XPath="/catalog/book"
DataFile="~/XMLFile.xml">
</asp:XmlDataSource>
</form>
</body>
</html>
ie I've defined no LayoutTemplate or ItemTemplate - we'll load these dynamically. The only other change is I've specified an ItemPlaceholderID on the ListView. We'll see why in a second.
using System;
using System.Web.UI;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ListView1.LayoutCreated += new EventHandler(ListView1_LayoutCreated);
ListView1.LayoutTemplate = LoadTemplate("LayoutTemplate.ascx");
ListView1.ItemTemplate = LoadTemplate("ItemTemplate.ascx");
}
void ListView1_LayoutCreated(object sender, EventArgs e)
{
//remove the layout template
ListView1.Controls.RemoveAt(0);
//recreate it
Control newLayoutContainer = new Control();
ListView1.LayoutTemplate.InstantiateIn(newLayoutContainer);
var userControl = newLayoutContainer.Controls[0];
userControl.ID = "MyLayout";
ListView1.Controls.Add(newLayoutContainer);
}
}
If you just go ahead and load the templates from the UserControls, you'll get the yellow screen of death telling you "An item placeholder must be specified on ListView 'ListView1'. Specify an item placeholder by setting a control's ID property to "itemPlaceholder". The item placeholder control must also specify runat="server"." The ListView simply can't find the ItemPlaceholder.
The key here is that the UserControl is a naming container so the ListView can't find the ItemPlaceholderID because it's been modified to avoid naming clashes on the page. In the code above we recreate the LayoutTemplate and set the UserControl's ID to "MyLayout" allowing us to specify that the ItemPlaceholderID will be "MyLayout$itemPlaceholder".
You could reduce this by determining up front the "native" ID of the UserControl ("ctl01" in this case) and setting the ItemPlaceholderID property of the ListView to "ctl01$itemPlaceholder". This would allow you to dispense with the LayoutCreated handler altogether. Of course if your UserControl ID then changes, it's going to break.
posted @
2008-08-30 15:46 真见 阅读(12) |
评论 (0) |
编辑
昨天在美国的下午,微软发布了IE8 BETA2
在新版的IE8 Beta2中微软已经决定扩展OpenSearch一个新的搜索建议数据格式,用XML或json表示 。新格式将显示实时搜索结果,摘要,图像,甚至搜索结果分类。而任何网站所有者只要提供适当的格式即可,本文将教你如何添加搜索建议,但在看本文之前,强烈建议请先看我的以前的一篇文章 “协助用户搜寻您的网站 { 创建一个OpenSearch }”来了解一下OpenSearch。
我们之前可以在一些工具栏中见到此功能,Google 最近也启用了这个功能,现在 IE8 Beta2 中已经内置了这个。IE8 Beta2 的这个功能不仅提供了无缝搜索体验,还支持一些出色的搜索服务提供商的功能:
在下拉建议列表中,包括最流行的搜索建议,以及浏览历史中的记录。
Search suggestion的数据文件是通过一个新的MIME类型引用在OpenSearchDescription文件中的Url元素: application/x-suggestions+xml,如下:
<Url type="application/x-suggestions+xml" template="http://localhost:2192/SuggestionsXml.aspx?k={searchTerms}" />
前面已经说过 - 搜索建议数据格式可以是JSON或XML表示,这里演示XML格式,XML Search Suggestions 格式化规格如下(来自MSDN):
<?xml version="1.0"?>
<SearchSuggestion>
<Query>xbox</Query>
<Section>
<Separator title="My Text Suggestions"/>
<Item>
<Text>Xbox 360</Text>
<Description>The official Xbox website from Microsoft</Description>
<Url>http://www.xbox.com</Url>
</Item>
<Item>
<Text>Xbox cheats</Text>
<Description>Codes and walkthroughs</Description>
<Url>http://www.example.com/xboxcheatcodes.aspx</Url>
</Item>
<Item>
<Text>Xbox 360 games</Text>
<Description>Games and accessories</Description>
<Url>http://www.example.com/games</Url>
</Item>
<Separator />
...
</Section>
</SearchSuggestion>
如何创建Search AutoSuggestions
1.创建一个 OpenSearch Description 文件( provider.xml )
<?xml version="1.0" encoding="UTF-8" ?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>我的Search AutoSuggestions</ShortName>
<Url type="text/html" template="http://zzk.cnblogs.com/s?w={searchTerms}" />
<Url type="application/x-suggestions+xml" template="http://localhost:2192/SuggestionsXml.aspx?k={searchTerms}" />
<Image height="16" width="16" type="image/icon">http://www.cnblogs.com/favicon.ico</Image>
<InputEncoding>GBK</InputEncoding>
</OpenSearchDescription>
2.添加Search Suggestions 到 OpenSearch Description 文件,,我已经在上面( 步骤1 )写过了,就是这句:
<Url type="application/x-suggestions+xml" template="http://localhost:2192/SuggestionsXml.aspx?k={searchTerms}" />
3.注意:因为 URL元素的template 属性值 是以GET的形式向 http://localhost:2192/SuggestionsXml.aspx?k={searchTerms} 传QueryString值,,
我想说的是现在要创建一个处理程序 SuggestionsXml.aspx,而这个页面文件就是动态生成 XML Search Suggestions 数据的。
using System;
using System.Text;
using System.Data;
namespace SearchAutoSuggestions {
public partial class SuggestionsXml : System.Web.UI.Page {
protected void Page_Load ( object sender, EventArgs e ) {
if ( !this.Page.IsPostBack ) {
if ( Request.QueryString[ "k" ] != null ) {
string key = Server.UrlDecode ( Request.QueryString[ "k" ].ToString () );
//int index;
//if ( int.TryParse ( Request.QueryString[ "i" ].ToString (), out index ) ) {
StringBuilder sb = new StringBuilder ();
sb.Append ( "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" );
sb.Append ( "<SearchSuggestion version=\"2.0\" xmlns=\"http://opensearch.org/searchsuggest2\">\n" );
sb.AppendFormat ( "<Query>{0}</Query>\n", key );
sb.AppendFormat ( "<Section title=\"{0}\">\n", key );
DataRow[] drs = GetOneDataTable ().Select ( string.Format ( "name like '%{0}%'", key ) );
if ( drs.Length > 0 ) {
foreach ( DataRow dr in drs ) {
sb.Append ( "<Item>\n" );
sb.AppendFormat ( "<Text>ID号:{0}</Text>\n", dr[ "id" ].ToString () );
sb.AppendFormat ( "<Description>Name:{0}</Description>\n", dr[ "name" ].ToString () );
sb.AppendFormat ( "<Url>http://www.cnblogs.com/default.aspx?page={0}&paging=10</Url>\n", dr[ "id" ].ToString () );
sb.Append ( "<Image source=\"http://news.cnblogs.com/images/logo/IE7.jpg\" alt=\"altTip\" width=\"50\" height=\"50\" />\n" );
sb.Append ( "</Item>\n" );
}
}
else {
sb.Append ( "<Item>\n" );
sb.AppendFormat ( "<title>{0}</title>", key );
sb.AppendFormat ( "<Description>{0}</Description>", "查询无数据。" );
sb.Append ( "</Item>" );
}
sb.Append ( "</Section>\n" );
sb.Append ( "</SearchSuggestion>" );
Response.ContentType = "text/xml";
Response.Write ( sb.ToString () );
//}
}
}
}
private DataTable GetOneDataTable () {
var dt = new DataTable ();
dt.Columns.Add ( "id" );
dt.Columns.Add ( "name" );
for ( int i = 0; i < 10; i++ ) {
dt.Rows.Add ( dt.NewRow () );
dt.Rows[ i ][ "id" ] = i + 1;
dt.Rows[ i ][ "name" ] = i + 1 + "name";
}
return dt;
}
}
}
4.创建Search Providers
<a href="#" onclick="window.external.AddSearchProvider('provider.xml')">添加SearchProvider</a>
5.测试下效果。
没有可执行查询到数据时:
下载[175k]
有个情况,传值是中文的时候会出错,,可我不知道怎么解决,希望有朋友做好了能告诉我下,不甚感激。。。
posted @
2008-08-29 22:37 真见 阅读(473) |
评论 (0) |
编辑
Internet Explorer 8 (IE8)团队正式在博客中宣布推出 IE8 Beta2,并可以在 http://www.microsoft.com/ie8 下载。
Windows Internet Explorer 8 Beta 2 基于 Windows XP 系统:www.microsoft.com/downloads/details.aspx?FamilyId=33FB40FD-2EE2-476A-A152-ED03734691B3&displaylang=zh-cn
Windows Internet Explorer 8 Beta 2 基于 Windows Vista 和 Windows Server 2008 系统: www.microsoft.com/downloads/details.aspx?FamilyId=6EF71415-646F-4279-8B6B-193435AB2D80&displaylang=zh-cn
Windows Internet Explorer 8 Beta 2 基于 Windows Vista x64和 Windows Server 2008 x64 系统: www.microsoft.com/downloads/details.aspx?FamilyId=87809432-919C-44C0-AB3E-94C5B0ED03D6&displaylang=zh-cn
Windows Internet Explorer 8 Beta 2 基于 Windows Server 2003 SP2 系统: www.microsoft.com/downloads/details.aspx?FamilyId=104CC11B-A81C-420E-B896-A46116D64DEF&displaylang=zh-cn
Windows Internet Explorer 8 Beta 2 基于 Windows Server 2003 x64 系统: www.microsoft.com/downloads/details.aspx?FamilyId=3648ED9D-3A8F-4FD5-875B-A2E9E7D5ECBA&displaylang=zh-cn
Web Slice Templates for Internet Explorer 8 Beta 2( 源剪辑切片风格指南模板 ): www.microsoft.com/downloads/details.aspx?FamilyID=85d15e3b-db17-431f-bb63-dca3a81d42b8&DisplayLang=en
Windows Internet Explorer 8 Beta 2: Technology Overview for Enterprise and IT Pros( 技术概述和它的利弊 ): www.microsoft.com/downloads/details.aspx?FamilyID=bc9c6664-8782-4851-a932-359ce8b5bdb5&DisplayLang=en
Windows Internet Explorer 8 Beta 2 FAQ for Business( 常见问题解答 ): www.microsoft.com/downloads/details.aspx?FamilyID=74f4cdcb-dc18-494f-a113-69fdbe4605a5&DisplayLang=en
还有一个针对WS2008 / Vista SP1的RealPlayer更新:
Internet Explorer 8 Beta 2 的更新(KB957055)
Internet Explorer 8 Beta 2 基于 x64 系统的更新 (KB957055)
其他链接:
Windows Internet Explorer 8 主页:http://www.microsoft.com/windows/internet-explorer/beta/
IE博客:http://blogs.msdn.com/ie
IE8 Beta2 隐私浏览功能具体信息:
微软将该隐私浏览功能命名为 InPrivate,用户可以通过 InPrivate 管理自己所有的上网记录,支持删除部分 Cookies,而不是全部 Cookies。用户可以选择性的删除上网痕迹,也可以为自己喜欢的站点保留数据。
1. InPrivate 浏览(InPrivate Browsing)
允许用户控制 IE8 是否保存浏览历史,Cookies,以及其他数据。
2. 删除浏览历史 Delete Browsing History
管理已经访问过的网站的浏览历史,并新增退出 IE8 时清空浏览历史选项。
3. InPrivate 阻止 InPrivate Blocking
提示用户目前内容可以获取浏览历史,并提供选项是否阻止。
4. InPrivate 订阅 InPrivate Subscriptions
允许用户订阅 InPrivate 阻止中的网站列表以批量阻止或允许。
追加部分:
1.Accelerators
加速器
2.Web Slices
Web Slices
3.InPrivate browsing ( 浏览历史记录 )
4.Search Suggestions ( 搜索建议功能 )

5.SmartScreen Filter ( 智能过滤-安全功能 )

6.Compatibility View(相容性)

7.快捷键CTRL+F自带搜索功能

Internet Explorer GalleryBeta

posted @
2008-08-28 05:18 真见 阅读(2095) |
评论 (30) |
编辑
Web Client Software Factory v2.0包含了一个RealTimeSearchMonitor控件 提供实时搜索功能 来帮助你在ASP.NET中使用ASP.NET AJAX 局部更新网页。
此文章帮助你 如何在ASP.NET 中使用 RealTimeSearchMonitor控件,数据来自Northwind数据库的Customers表,数据访问是用企业库写的,当然你也可以使用别的任何方式返回数据源,,不过不用企业库写个SQL语句还真是够复杂!!!
先决条件
使用realtimesearchmonitor ,必须是在一个网站或Web应用程序项目中用,并要符合下列条件:
配置为目标的Microsoft 。 NET Framework 3.5 。
表单必须至少有一个搜索输入控件,如:TextBox控件。
搜索结果必须包含ASP.NET AJAX UpdatePanel控件中。
1.下载Web Client Software Factory v2.0, RealTimeSearchMonitor源代码路径是:Web Client Software Factory 2.0\Samples\RealTimeSearch\RealTimeSearch,编译通过,引用realtimesearch.dll到网站就行了。
2.拖放控件到页面
需要设置AssociatedUpdatePanelID属性指向UpdatePanel的ID,
需要设置ControlsToMonitor(集合)中的属性TargetID指向输入控件,eventname事件是可选的,如果没有设置该属性默认由TargetID的控件事件更新。
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:TextBox ID="TextBox1" OnTextChanged="TextBox1_TextChanged" runat="server" />
<rts:RealTimeSearchMonitor ID="CustomerRealTimeSearchMonitor" runat="server" Interval="700"
AssociatedUpdatePanelID="UpdatePanel">
<ControlsToMonitor>
<rts:ControlMonitorParameter TargetID="TextBox1" />
</ControlsToMonitor>
</rts:RealTimeSearchMonitor>
<asp:UpdatePanel ID="UpdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<hr />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CustomerID"
PageSize="10" AllowPaging="True" Width="690px" OnPageIndexChanging="GridView1_PageIndexChanging">
<Columns>
<asp:BoundField DataField="CustomerID" HeaderText="CustomerID" SortExpression="CustomerID" />
<asp:BoundField DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName" />
<asp:BoundField DataField="ContactName" HeaderText="ContactName" SortExpression="ContactName" />
<asp:BoundField DataField="ContactTitle" HeaderText="ContactTitle" SortExpression="ContactTitle" />
<asp:BoundField DataField="City" HeaderText="Zip" SortExpression="City" />
<asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
3.先看看效果:
4.事件代码
<script runat="server" language="C#">
protected void TextBox1_TextChanged ( object sender, EventArgs e ) {
GridViewDataBind ();
}
public static DataSet GetCustomers ( string prefixText ) {
Database db = DatabaseFactory.CreateDatabase ( "ConnectDB" );
string sql = null;
if ( string.IsNullOrEmpty ( prefixText ) )
sql = "select * from Customers";
else
sql = "select * from Customers WHERE CompanyName LIKE '"
+ prefixText + "%'";
return db.ExecuteDataSet ( CommandType.Text, sql );
}
protected void GridView1_PageIndexChanging ( object sender, GridViewPageEventArgs e ) {
this.GridView1.PageIndex = e.NewPageIndex;
GridViewDataBind ();
}
private void GridViewDataBind () {
this.GridView1.DataSource =
GetCustomers ( this.TextBox1.Text );
this.GridView1.DataBind ();
}
</script>
posted @
2008-08-26 11:12 真见 阅读(1208) |
评论 (3) |
编辑
posted @
2008-08-26 07:56 真见 阅读(1294) |
评论 (9) |
编辑
一,如何创建排序表
1.T-SQL创建一个排序表。
CREATE TABLE OrderTable(
[OrderId] [int] IDENTITY(1,1) NOT NULL,
[CustomerId] [int] NOT NULL,
[OrderTotal] [decimal](18, 0) NOT NULL
)
2.T-SQL插入数据到排序表。
Insert into OrderTable (CustomerId, OrderTotal)
Values (1,90),
(2,180),
(6,540)
3.查看结果,如果是在MSSQL2005中插入数据,会报 ',' 附近有语法错误。
二,新语句之MERGE,请参考:http://tech.it168.com/db/2007-07-24/200707242111781.shtml
据IT168技术文档上是说当要对2张表进行信息同步时(合并2张表),有三步操作要进行。首先要处理任何需要插入目标数据表的新行。其次是处理需要更新的已存在的行。最后要删除不再使用的旧行。 一个模板如下:
CREATE TABLE [dbo].[CustomerTable](
[CustomerId] [int] IDENTITY(1,1) NOT NULL,
[CustomerTotal] [decimal](18, 0) NULL,
[CustomerName] [varchar](50) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[CustomerTable] ADD DEFAULT ((0)) FOR [CustomerTotal]
GO
ALTER TABLE [dbo].[CustomerTable] ADD DEFAULT ('') FOR [CustomerName]
GO
现在我们使用MERGE同步数据:
Merge CustomerTable
Using ( Select CustomerId, OrderTotal From OrderTable ) As OrderSrc (CustId, Amount)
On CustomerTable.CustomerId = OrderSrc.CustId
When MATCHED AND OrderSrc.CustId = 0 THEN
DELETE
When Matched Then
Update Set CustomerTotal = CustomerTotal + OrderSrc.Amount
When Not Matched Then
Insert (CustomerName,CustomerTotal) values (GetDate(), OrderSrc.Amount);
我也没理解,,还是说说目前对次语句的理解:
目标表(需要作用的表)是CustomerTable,源表(参照表)是OrderTable
1.When Matched Then 表示 当2张表有一些共同点,就是说CustomerTable.CustomerId = OrderTable.CustomerId 的时候,OrderTable。CustomerTotal 中的值是 更新到CustomerTable。CustomerTotal 。 其实IT168 也提过,,MERGE就是针对join的。
2.When Not Matched Then 表示 当 OrderTable 中的记录在 CustomerTable 中没有,,就添加新行。
3.When MATCHED AND OrderSrc.CustId = 0 THEN 其实应该是 When Source Not Matched Then, 我不知道为什么 When Source Not Matched Then 会报错,,因此改成了
When MATCHED AND OrderSrc.CustId = 0 THEN, 这个逻辑其实因该是要表示当源表,,也就是OrderTable中一条数据都没有的话,就DELETE CustomerTable….,我这里没写出来这个逻辑。
MERGE虽然强大,但会在目标表中产生无关的数据…..
三,内置初始化变量
以前的是:
DECLARE @i int
SET @i = 10
现在是:
DECLARE @i int = 10
四,C#数学语法
现在是:
--DECLARE @i int
--SET @i = 10
SET @i += 10
五,微软新引进的 表值参数 Table-Value-Parameters (TVP)
我看到微软ADO的博客写了一个例子:
Create Type Songs_TableType as Table
(Title nvarchar(120) not null,
TrackNumber int)
I can now use this type in a stored procedure to pass a table as a parameter. The following T-Sql shows how to define a stored procedure that takes this type as a parameter. Note that I have skipped error handling for brevity.
create procedure AddSongs(
@ArtistName nvarchar(120),
@AlbumName nvarchar(120),
@Songs Songs_TableType READONLY)
as
begin
-- Add the Artist
Declare @ArtistID int
insert into Artists values (@ArtistName)
select @ArtistID = SCOPE_IDENTITY()
-- Add the Album
Declare @AlbumID int
insert into Albums values (@AlbumName, @ArtistID)
select @AlbumID = SCOPE_IDENTITY()
-- Insert songs
insert into Songs
select title, trackNumber, @AlbumID, @ArtistID
from @Songs
end
但是看得不是很明白,下面是我的简写:
CREATE TYPE MyTableType AS TABLE (CustomerId int, OrderTotal int)
DECLARE @myTableType MyTableType INSERT @myTableType SELECT 6, 7
Insert into OrderTable Select CustomerId, OrderTotal from @myTableType
完了,另外,有兴趣的可以看看MSDN的网站http://msdn.microsoft.com/zh-cn/library/ms144275.aspx
posted @
2008-08-25 13:12 真见 阅读(1758) |
评论 (10) |
编辑
Management Studio首次出现在MSSQL2005中,到MSSQL2008中已经成为了一个更成功的产品。其中在SSMS2008中最重要的特性如下:
1.活动监视器 2.对象资源管理器详细信息 3.搜索 4.查询编辑器之IntelliSense 5.查询编辑器之T-SQL调试 这些只是部分关键功能,其他的功能你可以亲自使用SSMS来发现,祝各位发现的隐藏技巧越来越多。。
一。活动监视器
1.在SSMS2008中 如何开启活动监视器:右键Sql Server服务器名称 - 活动和监视器。。如下图:
你会看到,08的活动监视与05的是完全不同,在 “概述” 栏下你会立马看到4个图,第一个是动态的% CPU处理时间,第二个是等待的任务,第三个是数据库I/O,第四个是批请求。
活动监视器主要用在 当你需要这方面的资料的时候,你必须看,当你发现服务器很怪的时候,你也必须查看发生了什么事情。。。
2.进程,如图:
在进程的列表中,你可以对它们排序,以及对每一个SPID启动Profiler,用来分析SPID,如下图:
3.资源等待,如图:
因为我根本就没有用,所以效果不明显。。主要用在有哪些正在等待的资源将要在服务器上发生以及可以查资源瓶颈。
4.数据文件I/O,如图:
如果你怀疑某个数据库在磁盘I/O上是不稳定的,你可以在这里筛选快速查到其使用的数据库文件。。
5.最近耗费大量资源的查询,如图:
@如果你有性能问题,但是你有很多的操作语句,,那么使用该工具就可以显示近期最耗费大量资源的查询, 也是目前最快速的找到。。。如果你右键点击…….。
还得提示另一个技巧,,当你把鼠标放在文字上,,会有Tool Tip提示更多的资料。。
二。对象资源管理器详细信息
值得提醒的是SQL Server 2005中的对象资源管理器详细信息基本上没用,,绝大多数的人一会关掉它。。但是08确彻底改变了它,提供了很多资料,对象资源管理器详细信息的程度取决于所选定的对象。
注意,对象资源管理器详细信息 窗口默认情况是不显示的,你可以,这里比如选定一个数据库,然后按下F7即可调出对象资源管理器详细信息。( 也可以在视图菜单中选择 )