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

浙公网安备 33010602011771号