分类: 数据库开发技术
2008-05-28 11:15:18
SQL Server的一些小技巧
·假设admin_comments是ntext类型,不能直接用另外的ntext来赋值。可以用转换到nvarchar(8000)来过渡。例如:
UPDATE meta SET admin_comments = (SELECT TOP 1 CAST(admin_comments As varchar(8000)) FROM meta WHERE reference_code = @reference_code ORDER BY lastUpdate)
WHERE meta_id = @id
·察看纪录有没有重复,如果重复打印出重复的纪录个数:
SELECT [col], COUNT [col] AS Expr1
FROM [table]
GROUP BY [col]
HAVING (COUNT([col]) > 1)
详细介绍见以前的文章:
http://blog.csdn.net/snleo/archive/2006/05/12/726715.aspx