易截截图软件、单文件、免安装、纯绿色、仅160KB

将数据库表中的数据转为sql中的insert语句

 set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
--将表数据生成SQL脚本的存储过程
ALTER PROCEDURE [UspOutputData]
@tablename sysname
AS
declare @column varchar(1000)
declare @columndata varchar(1000)
declare @sql varchar(4000)
declare @xtype tinyint
declare @name sysname
declare @objectId int
declare @objectname sysname
declare @ident int
set nocount on
set @objectId=object_id(@tablename)
if @objectId is null -- 判断对象是否存在
begin
print 'The object not exists'
return
end
set @objectname=rtrim(object_name(@objectId))
if @objectname is null or charindex(@objectname,@tablename)=0 --此判断不严密
begin
print 'object not in current database'
return
end
if OBJECTPROPERTY(@objectId,'IsTable') < > 1 -- 判断对象是否是table
begin
print 'The object is not table'
return
end
select @ident=status&0x80 from syscolumns where id=@objectid and status&0x80=0x80
if @ident is not null
print 'SET IDENTITY_INSERT '+@TableName+' ON'
declare syscolumns_cursor cursor
for select c.name,c.xtype from syscolumns c where c.id=@objectid order by c.colid
open syscolumns_cursor
set @column=''
set @columndata=''
fetch next from syscolumns_cursor into @name,@xtype
while @@fetch_status < >-1
begin
if @@fetch_status < >-2
begin
if @xtype not in(189,34,35,99,98) --timestamp不需处理,image,text,ntext,sql_variant 暂时不处理
begin
set @column=@column+case when len(@column)=0 then'' else ','end+@name
set @columndata=@columndata+case when len(@columndata)=0 then '' else ','','','
end
+case when @xtype in(167,175) then '''''''''+'+@name+'+''''''''' --varchar,char
when @xtype in(231,239) then '''N''''''+'+@name+'+''''''''' --nvarchar,nchar
when @xtype=61 then '''''''''+co


相关文档:

SQL语句优化实践之一SQL_TRACE

SQL语句优化实践之一SQL_TRACE
 
环境:在PL/sql上调试数据
Pl/sql developer工具连接实例后即作为一个用户进程占用一个session;
 
select * from  v$session t  where t.PROGRAM='plsqldev.exe' and  t.USERNAME='DZJC'
查询结果显示了几个关键的字段
SADDR   RAW(4)  S ......

Sql 查询当天、本周、本月记录

Sql代码:Powered by chenjiazi
--查询当天:   
select * from info where DateDiff(dd,datetime,getdate())=0   
  
--查询24小时内的:   
select * from info where DateDiff(hh,datetime,getDate())<=24   
  
--info为表名,datetime为数 ......

在PHP中全面阻止SQL注入式攻击之二

一、 注入式攻击的类型
  可能存在许多不同类型的攻击动机,但是乍看上去,似乎存在更多的类型。这是非常真实的-如果恶意用户发现了一个能够执行多个查询的办法的话。本文后面,我们会对此作详细讨论。
  如果你的脚本正在执行一个SELECT指令,那么,攻击者可以强迫显示一个表格中的每一行记录-通过把一个例如"1=1"这 ......

SQL重复记录查询删除

1
、查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断
select

*

from
people
where
peopleId
in
(
select
   peopleId  
from
   people  
group
  
by
   peopleId  
having
  
cou ......

SQL server不能远程连接

这段时间碰到一个很奇怪的问题:SQL server不能远程连接。命名管道和TCP/IP协议都已启用,防火墙也关闭了等等,但就是不能远程连接数据库。终于找到原因了,当输入数据库服务器实例名时应:\,, 平常一般不用附加端口号的。 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号