摘要:select distinctb.namefrom dbo.syscomments a, dbo.sysobjects bwhere a.id=b.id and b.xtype='p' and a.text like '%text%'order by name
阅读全文
摘要:declare @i int set @i=1 while @i <101 begin INSERT INTO [TMS_V4].[dbo].[TB_GPSDeviceInfo] ([DeviceCode] ,[CompanyCode] ,[Status] ,[Remarks] ,[CreateUserName] ,[CreateBy] ,[CreateOn]) select 'KLD'+right('000'+ltrim(@i),3) ,'SZKLD',1,'','SYSTEM','SYSTEM
阅读全文
摘要:WITH ModuleInfo AS(select * from Base_Module where Code='HRAdmin'UNION ALLselect a.* from Base_Module AS a,ModuleInfo AS b WHERE a.parentid = b.id and a.Enabled=1 and a.DeletionStateCode=0)SELECT * FROM ModuleInfoorder by SortCode
阅读全文
摘要:FOR XML PATH 有的人可能知道有的人可能不知道,其实它就是将查询结果集以XML形式展现,有了它我们可以简化我们的查询语句实现一些以前可能需要借助函数活存储过程来完成的工作。那么以一个实例为主.一.FOR XML PATH 简单介绍那么还是首先来介绍一下FOR XML PATH ,假设现在有一张兴趣爱好表(hobby)用来存放兴趣爱好,表结构如下:接下来我们来看应用FOR XML PATH的查询结果语句如下:SELECT*FROM@hobbyFORXMLPATH 结果:<row><hobbyID>1</hobbyID><hName>爬山&
阅读全文
摘要:电话号码这种比较长的数字,会变成float,如果转为varchar,就会变成科学计数法。先从float转为numeric(30,2),再转为varchar,搞定。
阅读全文
摘要:select sum( b.rows) from sysobjects a inner join sysindexes b on a.id = b.id where a.type = 'u' and b.indid in (0, 1)
阅读全文
摘要:declare @BizNo varchar(30)declare OrderID cursor for select TruckNo from FT_Truck where Supplier='' and OccurDate between '2010-12-03' and getdate() open OrderID; fetch OrderID into @BizNo; while(@@FETCH_STATUS=0) begin EXEC [TF_Cala_Order_Cost_AP_SP] @ACTIONTYPE='Cala_Appl_Quotation_A
阅读全文
摘要:1、打开PowerDesigner12,在菜单中按照如下方式进行操作 file-Reverse Engineer-DataBase 点击后,弹出 New Physical Data Model 的对话框2、在General选项卡中 Model name:模板名字,自己命名。 DMBMS :根据需要选择,我选择的是Microsoft SQL Server 2000 点确定后弹出 Database Reverse Engineering Option 对话框3 Selection选项卡中,选中Using a data source选项 注意如果是第一次导入数据,需要你先自己配制ODBC数据源
阅读全文
摘要:ALTER proc Full_Search(@string varchar(50)) as begin declare @tbname varchar(50) declare tbroy cursor for select name from sysobjects where xtype= 'u ' --第一个游标遍历所有的表 open tbroy fetch next from tbroy i...
阅读全文
摘要:1、update a set a.p2=b.p2,a.bztks=b.bztks from Product a,price b where a.hpbm=b.hpbm2、update Product set Product.p2=price.p2 From Product,price WHERE Product.hpbm=price.hpbm
阅读全文
摘要:dbcc checkident(test1, reseed, 0)其中 test1 是表名称。事实上可以将标志的当前值设定到任意的值。下一次插入得值将会是这个当前值 + 1.比如:dbcc checkident(test1, reseed, 10)insert into test1 (name) values('zhangsan')得到的新纪录的 id 是 11.如果重设得值会导致插入后产生重复也...
阅读全文
摘要:select datepart(weekday,getdate()) 得到今天星期几select datepart(week,getdate()) 得到这周是第几周
阅读全文