日期:2014-05-18 浏览次数:20685 次
---------------------------- -- Author :fredrickhu(小F,向高手学习) -- Date :2011-04-01 14:01:35 -- Verstion: -- Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86) -- Jul 9 2008 14:43:34 -- Copyright (c) 1988-2008 Microsoft Corporation -- Enterprise Edition on Windows NT 5.2 <X86> (Build 3790: Service Pack 2) -- ---------------------------- --> 测试数据:[tb] if object_id('[tb]') is not null drop table [tb] go create table [tb]([col1] text,[col2] text) insert [tb] select 'a','t' union all select 'a','t' union all select 'a','t' --------------开始查询-------------------------- select distinct (CAST (col1 as varchar(10))),(CAST (col2 as varchar(10))) from tb ----------------结果---------------------------- /* ---------- ---------- a t (1 行受影响) */