打印本文 打印本文 关闭窗口 关闭窗口
收藏几段SQL语句和存储过程
作者:武汉SEO闵涛  文章来源:敏韬网  点击数4804  更新时间:2007/11/14 10:58:59  文章录入:mintao  责任编辑:mintao
)'''' 

              PRINT @sql

              print @sample

              print @tbl

              EXEC SP_EXECUTESQL @sql,N''''@sample nvarchar(30) OUTPUT'''',@sample OUTPUT

              INSERT INTO #tc SELECT *,ltrim(ISNULL(@maxlen,0)) as MaxLenUsed,

                     convert(nchar(20),ltrim(ISNULL(@sample,'''' ''''))) as Sample,'''' '''' Comment FROM #t where TableName=@tbl and FieldName=@fld

       END

       FETCH NEXT FROM read_cursor INTO @tbl,@fld

END

 

CLOSE read_cursor

DEALLOCATE read_cursor

GO

 

SET ANSI_NULLS ON

GO

SET NOCOUNT OFF

GO

select count(*)  from #t

DROP TABLE #t

GO

 

select count(*)-1  from #tc

 

select * into ##tx from #tc order by tablename

DROP TABLE #tc

 

--select * from ##tx

 

declare @db nvarchar(60),@sql nvarchar(3000)

set @db=db_name()

--请修改用户名和口令 导出到Excel

set @sql=''''exec master.dbo.xp_cmdshell ''''''''bcp ..dbo.##tx out c:\''''+@db+''''_exp.xls -w -C936 -Usa -Psa ''''''''''''

print @sql

exec(@sql)

GO

DROP TABLE ##tx

GO

 

 

 

-- ======================================================

--根据表中数据生成insert语句的存储过程

--建立存储过程,执行 spGenInsertSQL 表名

--

上一页  [1] [2] [3] [4] [5] [6] [7] [8]  下一页

打印本文 打印本文 关闭窗口 关闭窗口