2006-12-22

收藏几段SQL Server语句和存储过程

来源: CSDN 作者:shell 评论 0 条
 
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 表名

--感谢playyuer

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

create proc spGenInsertSQL (@tablename varchar(256))
as
begin
declare @sql varchar(8000)
declare @sqlValues
共16页: 上一页 [1] [2] [3] [4] 5 [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] 下一页

(本文仅表明作者个人观点,不代表本站及其管理员立场.) 推荐 收藏 投稿 打印 返回 关闭
上一篇:精妙的SQL和SQL SERVER 与ACCESS、EXCEL的数据导入导出转换  
下一篇:Oracle与SQL Server在企业应用的比较
    评论加载中…
 推荐文章
     

网站首页  -  网站地图 -   站长论坛  -  网站投稿  -    -  网站管理
Copyright © 2008 芜湖站长站 All Rights Reserved 皖ICP备07500611号