Private Function overpunchDec(def As String) As Decimal
This is my technical area for troubleshooting and learning new programming skills and much more. Here, you will find answers on a wide range of technologies such as AI, Machine Learning, OpenAI, Databricks, ASP.NET, C#, Python, Microsoft Access, MySQL, Amazon Web Services, SQL Server, PL/SQL, JD Edwards, SAS, Salesforce, APIs, MVC, and many others. Please feel free to visit and join the discussion!
Monday, January 30, 2023
Overpunch characters vb.net Function for Money & decimal
Sunday, January 22, 2023
VB.NET Read/Parse text file and Insert Data into SQL Server Table
VB.NET Read text file and Insert Data into SQL Server Table
Dim FILE_NAME As String = "c:/test/FileToUpload_20230102.013721.txt"
Wednesday, December 21, 2022
Tuesday, December 20, 2022
Wednesday, September 21, 2022
PowerBI run SP in DirectQuery
When I try to run a Stored Procedure in PowerBI getting this error
Incorrect syntax near the keyword 'EXEC'. Incorrect syntax near ')'.
You may need to configure SQL Server , but after all setup , you have to do following
Create the SP, and use in OPENROWSET as following , test this is in SSMS
SELECT * FROM OPENROWSET('SQLNCLI','server=DEVSERVER;Persist Security Info=True;UID=User;PWD=Password',
'exec budget.[dbo].[SP_TB_Test_Delthis_new]')
If this is working fine create a view as following:-
Create view [dbo].[VTest_dataTB_Delthis] as
SELECT * FROM OPENROWSET('SQLNCLI','server=DEVSERVER;Persist Security Info=True;UID=User;PWD=Password',
'exec budget.[dbo].[SP_TB_Test_Delthis_new]')
use this in Power BI as following :
Tuesday, September 20, 2022
Ad Hoc Distributed Queries turned off as part of the security configuration
Msg 15281, Level 16, State 1, Procedure PBIView_encrypted_Test1, Line 6 [Batch Start Line 0]
SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', search for 'Ad Hoc Distributed Queries' in SQL Server Books Online.
Tuesday, September 13, 2022
REBUILD indexes and update Stat SQL Server
Sometime when you load data, we are not able to get fast access using application. In order to fix this do following:-
ALTER INDEX ALL ON TBL_PlanBUDGET REBUILD WITH (ONLINE = ON, SORT_IN_TEMPDB = ON, FILLFACTOR = 80)
Update STATISTICS TBL_PlanBUDGET
Thursday, August 18, 2022
GRANT Permission SQL Server
GRANT EXECUTE, SELECT, UPDATE, INSERT, DELETE ON SCHEMA::ABC_EXT TO [MMC\JDEDEV]
Friday, July 29, 2022
Convert From date and to date in Julian , JD Edwards in VBA
Dim FrmDateImp
Dim ToDateImp
Dim tmpToDateImp
FrmDateImp =
Right(STR(PERIOD_BEG), 2) & "/01/" &
Mid(str(PERIOD_BEG), 2, 4)
tmpToDateImp = Right(STR(PERIOD_END),
2) & "/01/" & Mid(str(PERIOD_END), 2, 4)
ToDateImp =
DateSerial(YEAR(tmpToDateImp), Month(tmpToDateImp) + 1, 0)
Dim FrmDate_DGJ As Long
Dim ToDate_DGJ As Long
FrmDate_DGJ = ((DatePart("YYYY", FrmDateImp) - 1900) * 1000) + DatePart("y", FrmDateImp)
ToDate_DGJ = ((DatePart("YYYY", ToDateImp) - 1900)
* 1000) + DatePart("y", ToDateImp)
QryDateSummaryStr = "GLDGJ BETWEEN
'" & FrmDate_DGJ & "' and '" & ToDate_DGJ &
"'"
Wednesday, July 27, 2022
Change Date Format Excel Formula
Change date format excel formula, this is good for developer too, who wants to create SQL statement from excel cell.
=TEXT(B3,"mm/dd/yyyy")
=TEXT(B3,"mm-dd-yyyy")
Tuesday, July 26, 2022
Dynamic SQL table columns for dates in Aging report, SQL Server
How to create Dynamic SQL table columns for dates in Aging report JD Edwards, SQL Server
DECLARE @SQL_STR VARCHAR(8000)
DECLARE @DueDate VARCHAR(80)
DECLARE @DueDate14 VARCHAR(80)
DECLARE @DueDate28 VARCHAR(80)
DECLARE @DueDateAfter28 VARCHAR(80)
SET @DueDate = '['+'Due as of ' +CONVERT(VARCHAR(10), GETDATE()+1, 101)+'],'
SET @DueDate14 = '['+'Due as of ' +CONVERT(VARCHAR(10), GETDATE()+14, 101)+'],'
SET @DueDate28 = '['+'Due as of ' +CONVERT(VARCHAR(10), GETDATE()+28, 101)+'],'
SET @DueDateAfter28 = '['+'Due After ' +CONVERT(VARCHAR(10), GETDATE()+28, 101)+'],'
SET @SQL_STR =
'SELECT RPAN8 AS Supplier_Number, sup.ABALPH AS Supplier_name,
RPPST AS Pay_Stat, RPPYIN AS Pay_Inst, RPAN8 AS Payee_Number, PR.ABALPH AS Payee_Name,
RPDCT AS Doc_Type, RPDOC AS Doc_Number, RPSFX AS ITM, RPKCO AS CO, RPVINV AS Invoice_Number,
[dbo].[JDT_JTG](RPDIVJ) AS Invoice_Date,
[dbo].[JDT_JTG](RPDDJ) AS Due_Date,
CASE WHEN [dbo].[JDT_JTG](RPDDJ) BETWEEN CONVERT(VARCHAR(10), GETDATE(), 101) and CONVERT(VARCHAR(10), GETDATE()+1, 101)
THEN RPAG/100
ELSE 0 END '+ @DueDate + '
CASE WHEN [dbo].[JDT_JTG](RPDDJ) BETWEEN CONVERT(VARCHAR(10), GETDATE()+2, 101) and CONVERT(VARCHAR(10), GETDATE()+14, 101)
THEN RPAG/100
ELSE 0 END '+ @DueDate14 + '
CASE WHEN [dbo].[JDT_JTG](RPDDJ) BETWEEN CONVERT(VARCHAR(10), GETDATE()+15, 101) and CONVERT(VARCHAR(10), GETDATE()+28, 101)
THEN RPAG/100
ELSE 0 END '+ @DueDate28 + '
CASE WHEN [dbo].[JDT_JTG](RPDDJ) > CONVERT(VARCHAR(10), GETDATE()+28, 101)
THEN RPAG/100
ELSE 0 END AS '+ @DueDateAfter28 + '
CASE WHEN [dbo].[JDT_JTG](RPDDJ) >= CONVERT(VARCHAR(10), GETDATE(), 101)
THEN RPAG/100
ELSE 0 END AS Total_Due
FROM MFDB.PRODDTA.F0411
LEFT OUTER JOIN MFDB.PRODDTA.F0101 Sup ON Sup.ABAN8 = RPAN8
LEFT OUTER JOIN MFDB.PRODDTA.F0101 PR ON PR.ABAN8 = RPAN8
WHERE RPFY = 22
--AND rpan8 = 642564
AND RPPST = ''A'';
'
--PRINT (@SQL_STR)
EXEC (@SQL_STR)
Saturday, July 23, 2022
Convert Calendar Date to Julian Date Excel VBA (JD Edwards style Date)
Convert Calendar Date to Julian Date Excel VBA (JD Edwards style Date)
Dim myDate As Date
myDate = "07/23/2022"
Debug.Print (((DatePart("YYYY", myDate)) - 1900) * 1000) + DatePart("y", myDate)
Wednesday, June 29, 2022
find a table column in stored procedure in SQL Server
SELECT distinct OBJECT_NAME (id)
FROM syscomments
WHERE text LIKE '%GLMCU%'
GO
Tuesday, June 14, 2022
DROP INDEX SQL Server
DROP INDEX SQL Server if exists
DROP INDEX IF EXISTS IDX_tbl_XXXData_RR ON tbl_XXXData_RR;
Monday, June 13, 2022
How to load Sql queries in SQL Server table
Sometimes we need to load SQL code in a sql table and run that code in any application. you can load long SQL code using following:-
1. make your query in one line.
2.Open an excel and add a column name in excel, paste that query in a excel cell.
3. Load this excel in SQL server using sql import wizard.
4. Create an insert statement to load in your main table with all the fields.
INSERT INTO table_sql(sqlname,sqldesc,date,user,sqlcode)
Select sqlname,sqldesc,date,user, Column01 sqlcode from YourUpoadedTable