sql语句生成器,sql语句生成器手机版

http://www.itjxue.com  2023-01-22 15:43  来源:未知  点击次数: 

结构化SQL生成器sql-generator

用 JSON 来轻松生成复杂的 SQL,大幅提高写 SQL 的效率。基于 Vue3 + TypeScript + Vite + Ant Design + MonacoEditor 实现。如果你要写一句复杂的 SQL,且 SQL 中很多代码是 相似 但又不相同的。那么推荐使用该工具,可以不用重复编写 SQL,更有利于修改、维护和理解。

填入表名列名条件自动生成SQL语句的工具?

ALTER proc [dbo].[proc_insert] (@tablename varchar(256),@where varchar(max))

as

begin

set nocount on

declare @sqlstr varchar(MAX)

declare @sqlstr1 varchar(MAX)

declare @sqlstr2 varchar(MAX)

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 =36 then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'replace('+a.name+','''''''','''''''''''')' + '+'''''''''+' end'

when a.xtype =127 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(20),'+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+','''''''','''''''''''')' + '+'''''''''+' end'

when a.xtype =108 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar('+convert(varchar(4),a.xprec+2)+'),'+a.name +')'+' end'

when a.xtype =231 then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'replace('+a.name+','''''''','''''''''''')' + '+'''''''''+' end'

when a.xtype =59 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(23),'+a.name +',2)'+' end'

when a.xtype =58 then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'convert(varchar(23),'+a.name +',121)'+ '+'''''''''+' end'

when a.xtype =52 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(12),'+a.name +')'+' end'

when a.xtype =122 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(22),'+a.name +')'+' end'

when a.xtype =48 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(6),'+a.name +')'+' end'

-- when a.xtype =165 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 =167 then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'replace('+a.name+','''''''','''''''''''')' + '+'''''''''+' end'

else '''NULL'''

end as col,a.colid,a.name

from syscolumns a

where a.id = object_id(@tablename) and a.xtype 189 and a.xtype 34 and a.xtype 35 -- and a.xtype 36

AND COLUMNPROPERTY(a.id, a.name, 'IsIdentity') 1

)t order by colid

select @sqlstr=@sqlstr+left(@sqlstr2,len(@sqlstr2)-1)+') '+left(@sqlstr1,len(@sqlstr1)-3)+')'' from '+@tablename + ' where '+@where

-- print @sqlstr

exec(@sqlstr)

set nocount off

end

请问SQL语句生成器怎么设置连接自己的数据库?

新建一个文本文件,另存为 .udl 后缀,双击这个文件,在里面设置并成功连接到数据库,然后在SQL语句生成器中,选择使用数据连接文件,选中这个文件就行。

提供程序页面,填写你要连接的数据库类型

比如:MSSQL是 OLEDB for SQLServer ; Access是 Jet 4.0 OLE DB

点下一步填写登录信息,要勾选允许保存密码,然后点测试连接,如果登录信息没错的话,就会提示连接成功了

(责任编辑:IT教学网)

更多