Thursday, March 27, 2014

12 Period get values


declare @Period int, @Period_01 int,@Period_02 int,@Period_03 int,@Period_04 int,
@Period_05 int,@Period_06 int,@Period_07 int,@Period_08 int,@Period_09 int,@Period_10 int,@Period_11 int,@Period_12 int

declare @fy int
set @fy=14
set @Period=3

set @Period_12=@Period
if @Period-1=0    set @Period=12+@Period set @Period_11=@Period-1
if(@Period-2=0)   set @Period=12+@Period set @Period_10=@Period-2
if(@Period-3=0)   set @Period=12+@Period set @Period_09=@Period-3
if(@Period-4=0)   set @Period=12+@Period  set @Period_08=@Period-4
if(@Period-5=0)   set @Period=12+@Period set @Period_07=@Period-5
if(@Period-6=0)   set @Period=12+@Period set @Period_06=@Period-6
if(@Period-7=0)   set @Period=12+@Period set @Period_05=@Period-7
if(@Period-8=0)   set @Period=12+@Period set @Period_04=@Period-8
if(@Period-9=0)   set @Period=12+@Period set @Period_03=@Period-9
if(@Period-10=0)  set @Period=12+@Period set @Period_02=@Period-10
if(@Period-11=0)  set @Period=12+@Period set @Period_01=@Period-11

print @Period_12
print @Period_11
print @Period_10
print @Period_09
print @Period_08
print @Period_07
print @Period_06
print @Period_05
print @Period_04
print @Period_03
print @Period_02
print @Period_01

Wednesday, March 12, 2014

Write Data from Excel to Word Document

Step 1 : Reference Microsoft word into Excel

Sub showdatatomsword()
Dim wrdApp As Word.Application
Dim wDoc As Word.Document

Set wrdApp = CreateObject("word.application")
wrdApp.Visible = True

Set wDoc = wrdApp.Documents.Add

wDoc.Content.InsertAfter Range("A1")


End Sub


Monday, March 10, 2014

Global temporary table ##temp access from linked server

How to access,  Global temporary table ##temp access from linked server

SELECT * FROM OPENQUERY(LinkServername, 'SELECT * FROM ##temp2')

Monday, February 3, 2014

P6 Primavera Software Development Kit Tables and Fields

http://talentedcomponent.com/tcpm/SDK/GeneralTables&Fields.htm

Monday, January 27, 2014

Reporting UBE in Jd Edwards EnterpriseOne Report with Level break - 1080



Reporting UBE in JD Edwards EnterpriseOne Report with Level break - 1080

A simple report for beginner on group section.





Thursday, January 23, 2014

Convert number with comma with no zeros or in integer



replace(CONVERT(varchar, CAST(Actual AS money), 1),'.00','')

Saturday, January 4, 2014

Monday, December 30, 2013

Error JD Edwards EnterpriseOne 9.1 Not showing all webpage Elements

EnterpriseOne 9.1 Not showing all webpage Elements, you can fix as following:-



  1. Open the desktop, and then tap or click the Internet Explorer icon on the taskbar.

  2. Tap or click the Tools button Tools, and then tap or click Compatibility View settings.
  3. Under Add this website, enter the URL of the site you want to add to the list, and then tap or click Add.


--
Thanks
Shweta Sharma
http://www.svdeals.com

Wednesday, November 27, 2013

Error The query did not run, or the database table could not be opened. Excel 2010

Getting following error when running Stored proc with temp tables in EXCEL 2010


"The query did not run, or the database table could not be opened.
Check the database server or contact your database administrator. Make sure the external database is available and hasn't been moved or reorganized, then try the operation again."

Use folling code at the beginning of the stored proc 
SET NOCOUNT ON

Tuesday, November 26, 2013

Character index sql-server in loop , data in Table

declare

@bu varchar(300)

set

@bu=',0100000011,0100000050,0100000051,0100000026,'

create

table #tempmaintable( inpbu varchar(12))

DECLARE

@Str NVARCHAR(MAX)

SET

@Str = @bu

DECLARE

@Part NVARCHAR(MAX)

DECLARE

@IND INT

SET

@IND = CHARINDEX(',',@Str)

DECLARE

@EIND INT set @EIND = 0

WHILE

(@IND != LEN(@STR))

BEGIN

SET @EIND = ISNULL(((CHARINDEX(',', @Str, @IND + 1)) - @IND - 1), 0)

insert into #tempmaintable SELECT (SUBSTRING(@Str, (@IND + 1), @EIND))

SELECT @IND = ISNULL(CHARINDEX(',', @STR, @IND + 1), 0)

END

select

* from #tempmaintable

Monday, October 14, 2013

Friday, October 11, 2013

Working code for upload data from Excel to Sql-Server Using C#

Working code for  upload data from Excel 2010 to SQL-Server 2008 , working code.
C# , ASP.Net 4.0


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.Data.Common;
using System.Configuration;

public partial class Default3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {


        string ExcelContentType = "application/vnd.ms-excel";
        string Excel2010ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
        if (FileUpload1.HasFile)
        {
            //Check the Content Type of the file
            if (FileUpload1.PostedFile.ContentType == ExcelContentType || FileUpload1.PostedFile.ContentType == Excel2010ContentType)
            {
                try
                {
                    //Save file path
                    string path = string.Concat(Server.MapPath("~/File/"), FileUpload1.FileName);//Create this folder ib your project
                    //Save File as Temp then you can delete it if you want
                    FileUpload1.SaveAs(path);
                    
                    string excelConnectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=Excel 8.0", path);

                    // Create Connection to Excel Workbook
                    using (OleDbConnection connection =  new OleDbConnection(excelConnectionString))
                    {
                        OleDbCommand command = new OleDbCommand("Select * FROM [Sheet1$]", connection);

                        connection.Open();

                        // Create DbDataReader to Data Worksheet
                        using (DbDataReader dr = command.ExecuteReader())
                        {

                            string sqlConnectionString = ConnectionString;

                            // Bulk Copy to SQL Server
                            using (SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlConnectionString))
                            {
                                bulkCopy.DestinationTableName = "Tbl_YourTable";
                                bulkCopy.WriteToServer(dr);
                                Label5.Text = "The data has been exported successfully from Excel to SQL";
                            }
                        }
                    }
                }

                catch (Exception ex)
                {
                    Label5.Text = ex.Message;
                }
            }
        }
    }
    private string ConnectionString
    {
        get
        {
            string connectionString = ConfigurationManager.ConnectionStrings["connmy"].ConnectionString;
            return connectionString;
        }
    }

}