如何用distinct消除重复记录的同时又能选取多个字段值?
摘要:如何用distinct消除重复记录的同时又能选取多个字段值? 需求是:我要消除name字段值重复的记录,同时又要得到id字段的值,其中id是自增字段。 select distinct name from t1 能消除重复记录,但只能取一个字段,现在要同时取id,name这2个字段的值。 select distinct id,name from t1 可以取多个字段,但只能消除这2...
阅读全文
posted @
2012-05-30 13:22
瓦里奥
阅读(48538)
推荐(1)
nchar,nvarchar,ntext用在哪些地方?
摘要:nchar:Unicode定长字符型,一般用在长度变化不大的列。如姓名(2到4个汉字),电话(11位),身份证号(19位)。nvarchar:Unicode变长字符型,一般用在长度变化大的列。如家庭地址等。ntext:Unicode文本型,用在需要输入大段文字的字段,如简历,内容摘要等。
阅读全文
posted @
2012-02-24 10:22
瓦里奥
阅读(365)
推荐(0)
SQL中N $ # @的作用
摘要:declare @sql nvarchar(4000) set @sql= N'select @TotalRecords=count(*) from ' + N'(' + @sqlFullPopulate + N') a ' EXEC sp_executesql @sql,N'@TotalRecords int output', @TotalRecords output 问题:@sql...
阅读全文
posted @
2012-02-24 10:20
瓦里奥
阅读(25439)
推荐(1)