随笔分类 -  SQL

摘要:select distinct PurchasedByContactID as PurchasedByContactID into #SPfrom BASKET.. BaseOrderTracker(nolock )where OrderDate> '2014-2-1' and OrderDate... 阅读全文
posted @ 2014-10-20 15:59 MonkeyFather 阅读(353) 评论(0) 推荐(0)
摘要:use BASKETselect prd.PartID,prd.Quantity,prd.UnitRetailPrice,prd.ItemDesc,inf.orderdateinto #afrom Basket.dbo.BaseOrderItem prd(nolock)inner join Bas... 阅读全文
posted @ 2014-10-16 16:42 MonkeyFather 阅读(828) 评论(0) 推荐(0)
摘要:Use Basketselect convert(varchar(7),Orderdate,120) as YearMonth,OrderID,TotalCostinto #afrom Basket.dbo.BaseOrderTracker(nolock)where OrderDate >='201... 阅读全文
posted @ 2014-08-29 16:56 MonkeyFather 阅读(867) 评论(0) 推荐(0)
摘要:select left(convert(varchar,getdate(),21),7)select convert(varchar(7),getdate(),120)year(time)+'-'+month(time) 阅读全文
posted @ 2014-08-05 17:35 MonkeyFather 阅读(9179) 评论(0) 推荐(0)
摘要:1. 由于Bulk Insert通常配合格式化文件批量导入数据更方便,所以这里先介绍bcp工具导出格式化文件的方法。bcp是SQL Server提供的命令行实用工具提供了数据的导出、导入、格式文件导出等功能,导出格式化文件的语法如下:bcp 数据库名.用户名.表名 format nul -- 这里的... 阅读全文
posted @ 2014-07-25 14:29 MonkeyFather 阅读(850) 评论(0) 推荐(0)
摘要:use Omniture select VLR.YearMonth ,VLR.VisitorID ,VLR.ConsultantID ,VLR.Visits ,CL.LevelID ,CL.[Status] ,IfNew = case when (VLR.YearMonth=startmont... 阅读全文
posted @ 2014-07-25 14:03 MonkeyFather 阅读(203) 评论(0) 推荐(0)
摘要:EXEC sp_configure 'show advanced options', 1; RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1; EXEC sp_configure 'show advanced options', 0; RECONFI... 阅读全文
posted @ 2014-07-25 14:01 MonkeyFather 阅读(449) 评论(0) 推荐(0)
摘要:update TableNameset ConsultantID=right(cast('1000000000'+CONVERT(int,ConsultantID) as varchar(10)),9) 阅读全文
posted @ 2014-07-25 14:00 MonkeyFather 阅读(272) 评论(0) 推荐(0)
摘要:--添加一条记录 INSERT INTO tableName(col1,col2,col3) VALUES (1,2,3) --添加多条记录 INSERT INTO tableName(col1,col2,col3) SELECT 3,4,5 UNION ALL ... 阅读全文
posted @ 2014-07-25 13:58 MonkeyFather 阅读(470) 评论(0) 推荐(0)
摘要:BULK INSERT DBName.TableName FROM 'FileRoute' WITH ( Fieldterminator=',' ,rowterminator='\n' ,FirstRow=1) 阅读全文
posted @ 2014-07-25 13:55 MonkeyFather 阅读(141) 评论(0) 推荐(0)