SQL自动生成实体类
declare @tablename varchar(20)
select @tablename = 'o_ems'
-------------生成变量,使用表格形式(ctrl + D)输出,取第一个字段的值----------------------------------
select 'private '+
Case when t.name='varchar' Then 'string'
when t.name='char' Then 'string'
when t.name='datetime' Then 'datetime'
when t.name='int ' Then 'int'
when t.name='smallint' Then 'int'
when t.name='money' Then 'float'
when t.name='decimal' Then 'decimal'
when t.name='tinyint' Then 'byte'
else t.name end
+ ' _'+upper(substring(c.name,1,1))+lower(substring(c.name,2,(len(c.name)-1)))+';' as name /*,o.name,t.name,c.length,c.* ,isnull(m.text,'') */
from syscolumns c inner join sysobjects o on o.id=c.id
inner join systypes t on c.xtype=t.xtype
left outer join syscomments m on c.cdefault=m.id
where o.name =@tablename
order by c.id
-------------生成方法,使用文本形式(ctrl + T)输出----------------------------------
select '/// <summary>' +char(13)+char(10)+'///'+char(13)+char(10)+'/// <summary>'+char(13)+char(10)
+ 'public '+ Case when t.name='varchar' Then 'string'
when t.name='char' Then 'string'
when t.name='datetime' Then 'datetime'
when t.name='int' Then 'int'
when t.name='smallint' Then 'int'
when t.name='money' Then 'float'
when t.name='decimal' Then 'decimal'
when t.name='tinyint' Then 'byte'
else t.name end
+ ' ' +upper(substring(c.name,1,1))+lower(substring(c.name,2,(len(c.name)-1)))+char(13)+char(10)
+ '{' +char(13)
相关文档:
一、PowerDesigner生成sql问题
生成sql的方法是 Database -->Generate Database (Ctrl + G ) 但是提示
Generation aborted due to errors detected during the verification of the model.
解决方法: 将check model 去掉就可以了.其中,one file on是否需要按照表生成许多个sql(默认选上,即不需要)
& ......
select f.AGENTID as 'ID',
f.AGENTNAME as '姓名',
f.COMNAME as '公司简称',
c.REGISTDATE as '注册时间',
......
最近做项目的时候,遇到了一个问题。我主要是做一个Web Services给别人用的。别人传一个用户ID号过来,然后我将这个用户的所有好友的下载记录包装成一个DataSet返回去。 而根据用户ID号获取该用户的所有好友信息,则是通过另一个Web Services得到的,这里为FriendDS。
......
最近做项目,需要远程访问数据库,自己在查了些资料,总结了一下,希望对大家有帮助:
作者:shinehoo
一、配置SQL Server 2005
1)安装SQL Server 2005开发版;
2)开始->程序->Microsoft SQL Server 2005->SQL
Server 2005外围应用配置器,在打开的界面单击“服务的连接的外围应用配置器”,在打 ......
转自 http://database.ctocio.com.cn/222/9068222.shtml
1、没有索引或者没有用到索引(这是查询慢最常见的问题,是程序设计的缺陷)
2、I/O吞吐量小,形成了瓶颈效应。
3、没有创建计算列导致查询不优化。
4、内存不足
5、网络速度慢
6、查询出的数据量过大(可以采 ......