SELECT TOP 1 column FROM table
ORDER BY NEWID()
Ví dụ:
SELECT TOP 5 City_name FROM vw_ttv_mtd
ORDER BY NEWID()
Kiểm tra sự tồn tại
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MDF_Summary]') AND type in (N'U'))
print('ok')
else
print('ok2')
IF EXISTS (SELECT * FROM vw_ttv_mtd where city_name='linz')
drop table table_1
else
print('ok2')