摘要:
将数据导入exceL中,不想再C#里直接计算,直接将查询总数量合并 直接返回SELECT e_salecode as b,count(e_quantity) as a FROM e_stockout where e_stockid in(3,4) and e_senddate='2012-01-12' group by e_salecodeunion all select 'Total Count', count(e_quantity) FROM e_stockout where e_stockid in(3,4) and e_senddate='201 阅读全文
摘要:
select e_salecode as salecode ,count(e_quantity)as quantity from e_stockout where datediff(d,e_entertime,getdate())=0 and e_stockid =3 group by e_salecode执行后说从 char 数据类型到 datetime 数据类型的转换导致 datetime 值越界select e_salecode as salecode ,count(e_quantity)as quantity from e_stockout where datediff(d,con.. 阅读全文
摘要:
create proc [dbo].[sp_test1]as begin declare test cursor scroll for --声明游标select id,ordernumber from tb_order--给游标赋值open test --打开游标declare @id intdeclare @c varchar(100)while @@FETCH_STATUS=0 --利用@@FETCH_STATUS来循环begin fetch next from test into @id,@cinsert into tb_error(Message,TableNames)values(@ 阅读全文
摘要:
/* 连接数 */select connectnum=count(distinct net_address)-1 from master..sysprocesses/* 返回一组有关计算机和有关 SQL Server 可用资源及其已占用资源的有用杂项信息 */select * from sys.dm_os_sys_info/* 从操作系统返回内存信息 */select * from sys.dm_os_sys_memory/* 返回有关调用进程的虚拟地址空间中的页范围的信息 */select * from sys.dm_os_virtual_address_dump/* 命令提供了SQL Se 阅读全文
摘要:
简单点的直接返回查询的table对象CREATE FUNCTION Fun_GetReportNews(@type varchar(10)) RETURNS TABLE AS RETURN ( SELECT message,tablenames from tb_error WHERE tablenames = @type )调用:SELECT * FROM dbo.Fun_GetReportNews('')复杂点的 先创建一张临时表再返回表对象CREATE FUNCTION FUN_GetInfoList(@type varchar(10)) RETURNS @Table TA 阅读全文
摘要:
declare @test table(id int,name varchar(100))insert into @test(id,name)select ID,LastName from tb_OrderUserInfo where DATEDIFF(M,InTime,GETDATE())<3select * from @test 阅读全文
摘要:
CREATE FUNCTION [dbo].[GetSplitOfIndex]( @String NVARCHAR(MAX) , --要分割的字符串 @split NVARCHAR(10) , --分隔符号 @index INT --取第几个元素)RETURNS NVARCHAR(1024)AS BEGIN DECLARE @location INT DECLARE @start INT DECLARE @next INT DECLARE @seed INT SET @String = LTRIM(RTRIM(@String)) SET @start = 1 SET @next = 1 SE. 阅读全文
摘要:
update tb_order set UserID= a.ID from tb_OrderUserInfo a inner join tb_order p on p.rownum=a.rownumwhere DATEDIFF(M,p.InTime,GETDATE())<3tb_order 表和tb_OrderUserInfo 表对应同一行号tb_order 要取得tb_OrderUserInfo 的ID 阅读全文