--
--某table的column存在,傳回1;column不存在,傳回0 select count(name) from syscolumns where id=(select id from sysobjects where name='tableName')and name='columnName'
--某table的column存在,傳回1;column不存在,傳回0 select count(name) from syscolumns where id=(select id from sysobjects where name='tableName')and name='columnName'
SET ROWCOUNT 1 /*要先下此條件*/ GO UPDATE table_name set field_1 = GETDATE()WHERE field_2 = 'Y'
SELECT col2,col3,count(*) qty FROM table2 where col2 is nullgroup by col2,col3 having count(*) > 1
UPDATE TABLEA SET (b, c, d) = (SELECT b1, c1, d1 from TABLEB WHERE TABLEB.a1 = TABLEA.a and TABLEB.e1 > 40) WHERE EXISTS (SELECT 1 from TABLEB WHERE TABLEB.a1 = TABLEA.a and TABLEB.e1 > 40) update ( select a.fileld, b.fileld from TABLEA a, TABLE b where a.key = b.key) set fileld = fileld
select COLUMN2,COLUMN3 from TABLENAMEwhere len(COLUMN3) != datalength(convert(varchar(1000),COLUMN3))