惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
SegmentFault 最新的问题
Spread Privacy
Spread Privacy
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
Blog — PlanetScale
Blog — PlanetScale
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Apple Machine Learning Research
Apple Machine Learning Research
SecWiki News
SecWiki News
腾讯CDC
P
Privacy International News Feed
Webroot Blog
Webroot Blog
J
Java Code Geeks
爱范儿
爱范儿
A
About on SuperTechFans
S
Secure Thoughts
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
D
DataBreaches.Net
Cloudbric
Cloudbric
Security Archives - TechRepublic
Security Archives - TechRepublic
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Security Latest
Security Latest
Forbes - Security
Forbes - Security
小众软件
小众软件
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cybersecurity and Infrastructure Security Agency CISA
T
Threatpost
量子位
MongoDB | Blog
MongoDB | Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
月光博客
月光博客
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
Vercel News
Vercel News
Google Online Security Blog
Google Online Security Blog
云风的 BLOG
云风的 BLOG
GbyAI
GbyAI
S
Security @ Cisco Blogs
T
The Exploit Database - CXSecurity.com
Help Net Security
Help Net Security
V
Visual Studio Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 聂微东
P
Proofpoint News Feed
C
CERT Recently Published Vulnerability Notes
Attack and Defense Labs
Attack and Defense Labs

博客园 - Grok.Yao

sqlserver临时启用和关闭约束 string.format 参考 大O表示法 C# 日期格式化参考 查看sql语句的执行时间及缓存执行计划 查看索引执行次数 (转)JQuery有用的50段代码 查询指定日期区间内的每一天 FF和IE兼容的捕获回车事件问题 回车自动提交Form表单的问题 IE下 JS添加Select元素的option问题 VS中的常用快捷键,可以提高开发效率 ashx中使用Session问题 关于CSS控制TD换行与否的问题解决 TFS2008 无法撤销锁定的签出 C#中集合查询的问题! Sql获取随机时间 本地SQL脚本操作外部服务器结果集 RSA容器权限问题
将数据库记录倒为Insert语句的存储过程
Grok.Yao · 2011-06-15 · via 博客园 - Grok.Yao

GO
/****** Object:  StoredProcedure [dbo].[SinaBlog_Album_CreateAlbum]    Script Date: 06/15/2011 17:40:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:        <grokyao>
-- Create date: <2011-06-15>
-- Description:    <将表中数据倒为Insert语句>
-- =============================================
CREATE   PROCEDURE spGenInsertSQLHan (@TableName VARCHAR(256))  
 
AS
 
BEGIN 
 
    DECLARE @sql                VARCHAR(8000)  
 
    DECLARE @sqlValues            VARCHAR(8000)  
 
    SET @sql =' (' 
 
    SET @sqlValues = 'values (''+' 
 
    SELECT @sqlValues = @sqlValues + cols + ' + '','' + ' ,@sql = @sql + '[' + name + '],'   
 
    FROM   
 
      (SELECT CASE  
 
                WHEN xtype IN (48,52,56,59,60,62,104,106,108,122,127)                                  
 
                     THEN 'case when '+ name +' is null then ''NULL'' else ' + 'cast('+ name + ' as varchar)'+' end' 
 
                WHEN xtype in (58,61)  
 
                     THEN 'case when '+ name +' is null then ''NULL'' else '+''''''''' + ' + 'cast('+ name +' as varchar)'+ '+'''''''''+' end' 
 
                WHEN xtype in (167)  
 
                     THEN 'case when '+ name +' is null then ''NULL'' else '+''''''''' + ' + 'replace('+ name+','''''''','''''''''''')' + '+'''''''''+' end' 
 
                WHEN xtype in (231)  
 
                     THEN 'case when '+ name +' is null then ''NULL'' else '+'''N'''''' + ' + 'replace('+ name+','''''''','''''''''''')' + '+'''''''''+' end' 
 
                WHEN xtype in (175)  
 
                     THEN 'case when '+ name +' is null then ''NULL'' else '+''''''''' + ' + 'cast(replace('+ name+','''''''','''''''''''') as Char(' + cast(length as varchar)  + '))+'''''''''+' end' 
 
                WHEN xtype in (239)  
 
                     THEN 'case when '+ name +' is null then ''NULL'' else '+'''N'''''' + ' + 'cast(replace('+ name+','''''''','''''''''''') as Char(' + cast(length as varchar)  + '))+'''''''''+' end' 
 
                ELSE '''NULL''' 
 
              END AS Cols,name 
 
         FROM syscolumns    
 
        WHERE id = object_id(@tablename)   
 
      ) T   
 
    SET @sql ='select ''INSERT INTO ['+ @tablename + ']' + left(@sql,len(@sql)-1)+') ' + left(@sqlValues,len(@sqlValues)-4) + ')'' from '+@tablename  
 
 
    EXEC (@sql)  
 
END