Post by Goborijung at 2022-07-27 11:11:26 | ID: 1727
--Insert Into TM_PO(PONo,PODate,POType,VendCode,VendName,ItemCode,Description,Unit,UnitCost,CostAmount,ExchangeRate,POQty,Branch,Department,RecQty,AdditionalQty,NAVLineNo) --SELECT a.No_ --,a.[Order Date] --,'0' as POType --,a.[Buy-FROM Vendor No_] --,a.[Pay-to Name] --,b.No_ as ItemCode --,b.[Description] --,b.[Unit of Measure] --,cast(round(b.[Unit Cost],4) as decimal(18,4)) as [Unit Cost] --,cast(round(b.[Line Amount],2) as decimal(18,2)) as [Line Amount] --,cast(round(a.[Currency Factor],2) as decimal(18,2)) as [Currency Factor] --,cast(round(b.Quantity,2) as decimal(18,2)) as Quantity --,1 as Branch --,9 as Department --,'0' AS RecQty --,'0' as AdditQty --,b.[Line No_] --FROM [192.168.1.193].ThaiParfun_golive.dbo.[Thai Parfun Co_,Ltd$Purchase Header] a inner join [192.168.1.193].ThaiParfun_golive.dbo.[Thai Parfun Co_,Ltd$Purchase Line] b On a.No_ = b.[Document No_] --WHERE Type = 2 AND b.No_ <> '' And [Document No_] in('PSO21120194') --And b.No_ in('PKDT-M04215','PKDT-M04216','PKDT-M04217','PKDT-M04218','PKDT-M04219','PKDT-C86140','PKDT-C86141','PKDT-C86142','PKDT-C86143','PKDT-C86144','PKDT-C86147','PKDT-C86148','PKDT-C86149','PKDT-C86150','PKDT-C86151')
Post by Goborijung at 2021-04-22 16:10:59 | ID: 1137
ตัวอย่าง
Select cast(round(150.444444444444,4) as decimal(18,4)) as cutDigit -- 150.4444 หรือ Select CAST('150.4444444' AS DECIMAL(15, 2)) --150.44
Post by Goborijung at 2020-07-08 11:07:22 | ID: 660
Tools > Option... > Designers > เอาเครื่องหมายถูกหน้า Prevent saving changes that require ... ออก
Post by Goborijung at 2021-03-30 16:56:13 | ID: 346
https://stackoverflow.com/questions/39610133/how-to-import-an-excel-file-into-sql-server
Post by Goborijung at 2021-01-09 09:11:42 | ID: 289
SUBSTRING(expr,start,length) เลือกตัวอักษรใน expr โดยเริ่มจากค่าที่กำหนดใน start Ex. SELECT SUBSTRING('1234567',3,4) //Output : 3456
Post by Goborijung at 2020-02-04 16:26:22 | ID: 396
DECLARE @myDate date=GETDATE(); SELECT @myDate as Today; -- หา วันที่ปัจจุบัน /* รูปแบบ */ SELECT EOMONTH('วันเดือนปีปัจจุบัน' , -1 หรือ 1) as [End of last Month]; /* ตัวอย่าง */ SELECT EOMONTH(@myDate,-1) as [End of last Month]; -- หาวันที่สุดท้ายของ เดือนที่แล้ว SELECT EOMONTH(@myDate) as [End of this Month]; -- หาวันที่สุดท้ายของ เดือนปัจจุบัน SELECT EOMONTH(@myDate,1) as [End of next Month]; -- หาวันที่สุดท้ายของ เดือนถัดไป
Post by Goborijung at 2020-08-22 15:28:28 | ID: 398
credit: https://bit.ly/2Ox9CT4 SQL UNION ALL เป็นคำสั่งที่ใช้สำหรับการเลือกข้อมูลโดยทำการรวมจำนวนแถวระหว่าง Table เข้าด้วยกัน สำหรับ UNION และ UNION ALL ต่างกันตรงที่ UNION จะเลือกข้อมูลที่ระหว่าง 2 ตาราง ตามกฏ DISTINCT ของ Table นั้น ๆ คือข้อมูลใน Table หนึ่ง ๆ จะไม่ซ่ำกัน UNION ALL เลือกข้อมูลโดยไม่สนใจ คือเลือกเอาทั้งหมด
Post by Goborijung at 2020-02-23 10:29:14 | ID: 407
Ref: clickตัวอย่างคำสั่ง
DBCC CHECKIDENT ('[TableName]', RESEED, 0); -- Reset ให้ค่าเป็น 0 DBCC CHECKIDENT ('[TableName]', RESEED, 5); -- Reset ให้ค่าเป็น 5 เพราะจะ Insert ค่า 6 เข้าไป เป็นต้นView Current Ident
SELECT IDENT_CURRENT('FQATransfer') AS NUMIDENT;
Post by Goborijung at 2021-12-18 09:30:17 | ID: 1354
SELECT ROW_NUMBER() OVER(ORDER BY SalesYTD DESC) AS Row
Post by Goborijung at 2019-12-06 10:15:58 | ID: 213
ALTER TABLE table_name ADD column_name data_type NULL Ex. ALTER TABLE test ADD Address nvarchar(200) NULL