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')