SQL 中将一个表转化成建表语句的存储过程
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE proc pGetInsertSQL (@TableName varchar(256))
as
begin
set nocount on
declare @sqlstr varchar(4000)
declare @sqlstr1 varchar(4000)
declare @sqlstr2 varchar(4000)
select @sqlstr='select ''insert '+@tablename
select @sqlstr1=''
select @sqlstr2=' ('
select @sqlstr1= ' values ( ''+'
select @sqlstr1=@sqlstr1+col+'+'',''+' ,@sqlstr2=@sqlstr2+name +',' from (select case
-- when a.xtype =173 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar('+convert(varchar(4),a.length*2+2)+'),'+a.name +')'+' end'
when a.xtype =104 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(1),'+a.name +')'+' end'
when a.xtype =175 then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'replace('+a.name+','''''''','''''''''''')' + '+'''''''''+' end'
when a.xtype =61 then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'convert(varchar(23),'+a.name +',121)'+ '+'''''''''+' end'
when a.xtype =106 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar('+convert(varchar(4),a.xprec+2)+'),'+a.name +')'+' end'
when a.xtype =62 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(23),'+a.name +',2)'+' end'
when a.xtype =56 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(11),'+a.name +')'+' end'
when a.xtype =60 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(22),'+a.name +')'+' end'
when a.xtype =239 then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'replace('+a.name+','''
相关文档:
下载后解压缩就能直接使用了,但是是中文的,字体显示的不是很好,于是找到了换英文的办法:
由于1.5包含了多语言界面的支持,但是它是通过JVM来辨认系统语言的,所以当你的系统语言为中文的时候,它会使用中文界面。不过它的中文翻译并不完整,加上默认界面字体太小,使用中文会看着非常难受。如果想使用英文界面,需要修 ......
获取SQL Server的当前连接数
[转]http://www.cnblogs.com/confach/archive/2006/05/31/414156.html
首先声明:这个问题我没有解决
当网友问到我这个问题时,我也还以为很简单,以为SQL Server应该提供了对应的系统变量什么的.但是到目前为止,我还没有得到一个比较好的解决方案.可能很简单,,只不过我不知道罢了.希望如此..
......
DECLARE
TYPE list IS TABLE OF t_stu.project%TYPE INDEX BY BINARY_INTEGER;
project_list list;
v_pro_num NUMBER;
sql_str VARCHAR(255);
t_stu
SID SUBJECT SCORE
1 数学 &n ......
transaction 1:
------------------------------------------------------
begin transaction
update table1 set cola = 'str1'
Waitfor time '10:12:00'
update table2 set colb = 'str2'
rollback transaction
transaction 2:
---- ......
如要在一个hwsp表中填加字段:ylxs
alter table hwsp add column ylxs
ALTER TABLE 表 {ADD ADD{COLUMN 字段类型 [ (字长)] [NOT NULL] [CONSTRAINT 索引 ] |
ALTER COLUMN 字段类型 [(字长)] |
CONSTRAINT 多重字段索引 } |
&nbs ......