- 如何用一条sql语句查出所有数据类型为char的字段?
select * from syscolumns where xtype=175
CREATE TABLE TB1(NUM int)
insert tb1
SELECT 10000000 union all
SELECT 10000001
DECLARE @TIMES int,@OUTPUT int
SELECT @TIMES=100
WHILE(@TIMES>0)
BEGIN
SELECT @OUTPUT=FLOOR(rand()*100000000)
IF NOT EXISTS(SELECT 1 FROM TB1 WHERE @OUTPUT=NUM)
BEGIN
PRINT @OUTPUT
BREAK
END
ELSE
BEGIN
SET @TIMES=@TIMES-1
END
END
IF @TIMES=0
PRINT -1
- SQL 2000中的ntext类型数据怎么replace?
--如果小於8000 可以轉換成VARCHAR(8000) 2005 VARCHAR(MAX)來處理
IF OBJECT_ID('TEMPDB..#')IS NOT NULL DROP TABLE #
GO
CREATE TABLE #([NAME] TEXT)
INSERT # SELECT '張三'
INSERT # SELECT '李四'
SELECT REPLACE(CAST([NAME] AS VARCHAR(8000)),'張','王') FROM #
/*-----------------------------------------------------------------------------------------------------------
王三
李四
(影響 2 個資料列)
*/
create table tb(i int)
insert into tb select 2
insert into tb select 5
select top 1000 identity(int,1,1) as i into # from sysobjects
select #.i from # left join tb on #.i=tb.i
where tb.i is null
http://www.itpob.net/home/space.php?uid=1&do=blog&id=6
http://www.itpob.net/?action-viewnews-itemid-38030
http://www.itpob.net/?action-viewnews-itemid-38030