Monday 31 August 2015

Name Split Function In SQL



Create Function Dbo.Part
    (@Value Varchar(8000)
    ,@Part Int
    ,@Sep Char(1)
)Returns Varchar(8000)
As Begin
Declare @Start Int
Declare @Finish Int
Set @Start=1
Set @Finish=CharIndex(@Sep,@Value,@Start)
While (@Part>1 And @Finish>0)Begin
    Set @Start=@Finish+1
    Set @Finish=CharIndex(@Sep,@Value,@Start)
    Set @Part=@Part-1
End
If @Part>1 Set @Start=Len(@Value)+1 -- Not found
If @Finish=0 Set @Finish=Len(@Value)+1 -- Last token on line
Return SubString(@Value,@Start,@Finish-@Start)
End

Go

/*
  Execute Example
Declare @Name Varchar(100)='Thillai,raja,24,6'
Select
      Dbo.Part(@Name,1,',')As Name
      ,Dbo.Part(@Name,2,',')As Name1
      ,Dbo.Part(@Name,3,',')As Name2

Example Image:
*/  

Get Particular Day(Monday) Dates Between Two Dates Function In SQL

Create Function dbo.GetDaysName
    (@day1 Date
    ,@day2 Date
    ,@day varchar(10)
)Returns @t TABLE (Name VARCHAR(20))
As
Begin
Declare @i int =0
while @i<=DATEDIFF(DAY,@Day1,@day2)
Begin

 if  DATENAME(dw,DATEADD(day,@i,@Day1))=@day
 Begin
insert into @t Values(DATEADD(day,@i,@Day1))
 End
 set @i=@i+1
ENd
 RETURN
End

/*
Execute Example:

Select name from dbo.GetDaysName('2015-08-31','2015-10-01','Monday')

 It will list out only Monday date between these two dates
 In the above line you can use any day name .
 */

Monday 10 August 2015

Get System date in Microsoft Dynamics SL (VBA)



    Dim CurrDate As Sdate
    Dim sCurrDate As String
   
   
    Call GetSysDate(CurrDate)             '   GetDate Code
    sCurrDate = DateToStr(CurrDate)  ' Convert to string

Assign value to Textbox in Microsoft Dynamics SL

For better results use both syntax then only buffer and control also updated.

1.Assign value to table buffers
     Dim Serviceid As String
     Serviceid="Test"
     Call SetBufferValue("bsmservcall.servicecallid", Trim(Serviceid))

2.Assign value to textbox by control name
     Dim Serviceid As String
     Serviceid="Test"
     serr = SetObjectValue("cservicecallid", Trim(Serviceid))

  some time  the value was update but in screen it was not showing,in this time use the below code
       Call DispFields("form1", "")

Get Text box Value in Microsoft Dynamics SL


 Two type of  syntax available for  getting text box values

  1.Get value by Control Name(text box name)

       Dim myVariable  As String
       myVariable = GetObjectValue("controlName")

2.Get value by table buffer values

     Dim Siteid As String
    Call GetBufferValue("bintran.user1", Siteid)