1 Microsoft SQL Server features that can be used with the IBM i
Create and work with a Linked Server for your IBM i Copyright © 2012, Craig Pelkie, ALL RIGHTS RESERVED
Create and work with a Linked Server for your IBM i
Contents Create a Linked Server ....................................................................................................... 2
Create a library on your IBM i ........................................................................................... 2 Define a linked server ...................................................................................................... 2
IBM i Relational Database Directory Entries ...................................................................... 7
Work with Tables in the Linked Server ................................................................................ 8
Create a new database in SQL Server ................................................................................. 11
Work with the IBM i database from SQL Server .................................................................... 14
Use a SELECT INTO statement to populate a table in the SQL400 database form a table on your IBM i ........................................................................................................................... 14
Query the data in the SQL400.dbo.QCUST table .............................................................. 15
Attempt a SELECT INTO from SQL Server to the IBM i ........................................................ 16
Create the target IBM i table, use INSERT INTO ................................................................. 19
Run an SQL UPDATE statement from SQL Server to the IBM i .............................................. 27
Run an SQL DELETE statement from SQL Server to the IBM i .............................................. 31
Work with a batch of SQL statements ................................................................................. 32
Create a T-SQL batch script ............................................................................................ 32
Save the T-SQL batch script ........................................................................................... 34 Run the T-SQL batch file from a Windows Command Prompt ............................................... 36
Summary ..................................................................................................................... 41
Create a SQL Server Agent job to run the INSERT INTO on a schedule .................................... 42
Determine if the SQL Server Agent is running ................................................................... 42
Create a new Agent job .................................................................................................. 44
Enter General values for Agent Job Step 1 ..................................................................... 48
Enter Advanced values for Agent Job Step 1 ................................................................... 49
Enter General values for Agent Job Step 2 ..................................................................... 51
Enter Advanced values for Agent Job Step 2 ................................................................... 52 Enter General values for Agent Job Step 3 ..................................................................... 53
Enter Advanced values for Agent Job Step 3 ................................................................... 54
Set job schedule properties .......................................................................................... 56
Set the Notifications options ........................................................................................ 58
Disable the job, prepare for testing the job ....................................................................... 59
Review the Agent job's run history ................................................................................... 63
If the Agent Job ends in error ......................................................................................... 66
Disable the job ............................................................................................................. 67
Summary ....................................................................................................................... 67
CIlP
IWS
C
Njla
Als
D
F
Create aIn SQL Servocated on aProvider, the
In this lab, yWindows OLSQL Server
Create a _____ Enter
CRTLI
_____ Use tADVWO
CRTDU
Note: if youournal, andab, the file automaticall
As an alternibrary). Whschema.
Define a _____ Open
_____ In thServ
_____ You c(Figu
Figure 1: You
M
a Linkedver, a linkedanother serve other serv
you will defiLE DB ProvidManagemen
library or the followi
IB LIB(ADVW
the followingORKS:
UPOBJ OBJ(Q
u use the CRT start journis required ly starting jo
ative, you cen you crea
linked sen the SQL Se
e Object Exver Objects
can right-cliure 1). Selec
u can right-cli
Microsoft SQL Create an
Copyright ©
d Serverd server is a ver. Becausever can pote
ne and worder. You'll sent Studio.
n your IBng comman
ORKS) TEXT(
g CRTDUPOBJ
CUSTCDT) FR
TLIB commaaling the phto be journaournaling (f
can use the ate a schem
erver erver Manag
xplorer, expas item and e
ck either thct the item t
ick either the
Server featund work with © 2012, Craig
r persistent oe the connecentially be a
k with a linkee how you
BM i nd on your I
('SQL Serve
command o
ROMLIB(QIWS)
and shown ahysical file taled. See thfor OS/400 V
System i Naa, journalin
gement Stu
and the SQLexpand it.
e Server Oto create a N
sq
Server Obje
ures that can a Linked Serg Pelkie, ALL
object that dction to the ny type of d
ked server t can use da
IBM i to crea
r course te
on your IBM
) OBJTYPE(*
above, you hat you cop
he additionaV5R4 and a
avigator andg is automa
dio, if it is n
L Server tha
Objects itemNew Linke
ql02002
ects or the Lin
be used withrver for your RIGHTS RES
describes a linked servdata source
to your IBM tabase files
ate the libra
est library
M i to copy f
*FILE) TOLIB
also need topy. In some l PDF on thebove).
d create a natically start
not already
at you are c
m, or right-ced Server.
nked Servers
h the IBM i IBM i
SERVED
connection ver is create.
i, using the on the link
ary ADVWORKS
')
file QIWS/QCU
B(ADVWORKS)
o create a j of the stepse course we
new schemated for table
opened.
onnected to
click the Lin
menu item.
to a databaed using an
e IBM i Acceked server in
S:
USTCDT to lib
) DATA(*YES)
ournal reces used latereb site abou
a (an SQL-enes that are i
o and locate
nked Serve
2
ase OLE DB
ess for n the
rary
)
iver, a r in this t
nabled n the
e the
rs item
sql02003
F
_____ The Npage
Figure 2: On
M
New Linked and that O
the General p
Microsoft SQL Create an
Copyright ©
Server dialoOther data s
page, you sel
Server featund work with © 2012, Craig
og is displaysource is se
lect the provi
ures that can a Linked Serg Pelkie, ALL
yed (Figure elected.
ider to use fo
be used withrver for your RIGHTS RES
2). Be sure
or the connec
h the IBM i IBM i
SERVED
e that Gene
ction and set
ral is the se
the library lis
3
elected
sql02004
st.
4 Microsoft SQL Server features that can be used with the IBM i
Create and work with a Linked Server for your IBM i Copyright © 2012, Craig Pelkie, ALL RIGHTS RESERVED
_____ Enter the following information on the General page. DO NOT CLICK THE OK BUTTON AFTER ENTERING THIS INFORMATION.
Item Value
Linked server Enter a name to assign to the linked server. Suggested value: the TCP/IP host name of the IBM i that you are connecting to.
Provider IF YOU ARE USING System i Access for Windows V5Rx
Select the IBM DB2 UDB for iSeries IBMDA400 OLE DB Provider from the drop-down list.
Note: the IBMDA400 provider is the preferred provider. You may be able to use the IBMDASQL provider, although you may need to be at the most recent Service Level for it to work correctly. DO NOT select the IBMDARLA provider.
IF YOU ARE USING System i Access for Windows V6Rx
You can select either the IBM DB2 for i5/OS IBMDA400 OLE DB Provider or the IBM DB2 for i5/OS IBMDASQL OLE DB Provider from the drop-down list.
Product name You can enter any value here. Suggested value:
IBMDA400 if you are using IBMDA400 OLE DB Provider.
IBMDASQL if you are using the IBMDASQL OLE DB Provider.
Data source Enter the TCP/IP host name of the IBM i system that you are connecting to.
Provider string Enter the following blank-separated words, the = sign and a comma-separated list of libraries, followed by a closing semicolon:
Catalog Library List
Example:
Catalog Library List=ADVWORKS,QIWS;
Include the ADVWORKS library that you created earlier in this lab. You can enter any other libraries on your IBM i that you want. However, for your initial tests, you should limit the number of libraries that you use.
Note: if you mistype a library name (or enter the name of a library that does not yet exist on your IBM i), no error is indicated. The linked server will be created with the library list for libraries that do exist in the list that you specify.
Note: if you include a library that you are not authorized to, the library appears in the linked server list of libraries. However, when you try to access any file objects in that library through the linked server, an error message is returned to SQL Server.
Catalog Leave this entry blank unless you created the test library ADVWORKS in the non-default system Auxiliary Storage Pool (ASP).
If you created library ADVWORKS in a non-default ASP, enter the name of the ASP as the value for Catalog.
F
_____ Afterleft c
Figure 3: On
_____ On thEnterpass
_____ Click
Noteafter enteryou wlist a
_____ You sshow
_____ ExpaSyston yoentrythis s
Whenexpayour
• •
M
r entering thcorner of the
the Security
he Security r your IBM isword.
the OK but
e: you canno you create red on the Swill need to nd select th
should now wn in Figure
nd the linkeem Catalogour IBM i. Ty shown instep.)
n you expannd both of t IBM i via th
The TableThe View
Microsoft SQL Create an
Copyright ©
he informatie New Linke
page, you se
page (Figur user ID for
tton on the
ot change a the Linked Security pa delete and he Delete it
see the link 4.
ed server, thgs and anothe catalog
n the figure
nd the catalothose items he linked ser
es list includs list include
Server featund work with © 2012, Craig
on on the Ged Server dia
et the IBM i U
re 3), selectr Remote lo
Security pa
ny of the inServer. You
age. If you nrecreate theem).
ked server t
hen expand ther catalog
g name thae (S105HMNM)
og name, yo to see the rver definiti
des physicales logical fil
ures that can a Linked Serg Pelkie, ALL
General pagalog (Figure
User ID and P
t the Be maogin and en
age. The lin
formation tu can changneed to chane definition
hat you def
the Catalog name, whit you see w). (A descrip
ou will see elists of dataon.
files. les and SQL
be used withrver for your RIGHTS RES
ge, click thee 3).
Password for
ade using tnter your IB
ked server
hat you ente the user Inge the info (right-click
fined in the
ogs item. Yoch is the nawill not be ption of the
entries for Tabase file ob
L views.
h the IBM i IBM i
SERVED
Security it
the connectio
this securitBM i passwor
is created.
tered on theID and passormation on the item in
list of Linke
ou should seame of the l the same local datab
Tables and bjects that a
tem in the u
on.
ty context rd for With
e General psword that y the Genera the Linked
ed Servers, a
ee an entry ocal databa as the cataase entry fo
Views. Youare accessib
5
upper-
sql020041
option.
page you al page, d Server
as
for se entry alog ollows
u can le on
Fc
Noteyou aIBM iallowappe
Figure 4: Thecatalog. Note
M
e: the Tablesattempt to ai to the data
wed to accesars in the li
e linked servee: the list of t
Microsoft SQL Create an
Copyright ©
s and Viewsaccess data abase providss data in IBst of objects
er now appeatables that yo
Server featund work with © 2012, Craig
s lists may i in an unautder that youBM i objects s for the lin
rs in the list. ou see on you
ures that can a Linked Serg Pelkie, ALL
nclude objethorized obju used to cre that you arked server.
Expand it tour system wil
be used withrver for your RIGHTS RES
cts that youject, an erroeate the linre not autho
o see the catall be different
h the IBM i IBM i
SERVED
u are not auor message ked server. orized to, ev
alog and the t from the lis
uthorized to is sent from You are noven if the ob
tables that arst shown here
6
. When m the t
bject
sql02005
re in the e.
I
Ws
Oe
F
F
IBM i Relat
When you dspecified on
On the IBM entries on y
WRKRD
Figure 5 sho
Figure 5: This
M
tional Data
efine a linke the Genera
i, "databaseour IBM i by
DBDIRE
ows two rela
s is the WRKR
Microsoft SQL Create an
Copyright ©
abase Direc
ed server, thal page (Fig
es" are definy entering t
ational datab
RDBDIRE disp
Server featund work with © 2012, Craig
ctory Entrie
he link is togure 2).
ned using Rehe following
base directo
play, showing
ures that can a Linked Serg Pelkie, ALL
es
the *LOCAL
elational Dag command
ory entries o
g the *LOCAL
be used withrver for your RIGHTS RES
database e
atabase Dire on a 5250 c
on an IBM i
L database an
h the IBM i IBM i
SERVED
entry on the
ectory Entriecommand e
system.
nd a remote
IBM i that y
es. You can entry line:
database def
7
you
see the
sql020051
finition.
W
F
Fb
Work wit_____ In th
_____ RightNew
Figure 6: Use
_____ A SELwindoonly mousdispla
Notediffergene
Figure 7: A SEbeing invalid.
M
th Tablese Tables lis
t-click the Aw Query Edi
e the Script Ta
LECT statemow, as showthe columnsse over the ayed.
e: the tab herent. It doesrated when
ELECT statem
Microsoft SQL Create an
Copyright ©
in the List for your l
ADVWORKSitor Window
Table as featu
ent for the twn in Figures in the tab4-part table
eaders that s not matter a new tab o
ment for the t
Server featund work with © 2012, Craig
inked Serinked serve
S.QCUSTCDw menu ite
ure to generat
table is gen 7. Note thale that contae name that
are displayer what the topens.
table is gener
ures that can a Linked Serg Pelkie, ALL
rver r, locate the
DT item andms, as show
te a SELECT
erated in that the SELECain charactet the "invalid
ed on your tab header n
rated in the Q
be used withrver for your RIGHTS RES
e ADVWOR
select the Swn in Figure
statement fo
he SQL ServCT statementer data. Alsod" message
PC (SQLQunames are;
Query window
h the IBM i IBM i
SERVED
RKS.QCUST
Script Tabe 6.
or a table in t
ver Managemt that is geno note that shown in th
uery16.sql. the header
w. The table
TCDT item.
le as, SELE
the linked ser
ment Studionerated incl if you hovehe figure is
.., etc.) wills are autom
name is flagg
8
ECT to,
sql02006
rver.
o Query udes r the
l be matically
sql02007
ged as
F
F
_____ If youinval
Figure 8: The
_____ Click Resu
Figure 9: Clic
M
u hover the id (Figure 8
e column nam
the Executlts panel, as
k the Execute
Microsoft SQL Create an
Copyright ©
mouse ove).
mes will also b
te button tos shown in F
e button to ru
Server featund work with © 2012, Craig
er any of the
be flagged as
o run the SEFigure 9.
un the SELEC
ures that can a Linked Serg Pelkie, ALL
e column na
s invalid.
LECT statem
CT query. The
be used withrver for your RIGHTS RES
ames, the co
ment. The re
e results are
h the IBM i IBM i
SERVED
olumn is als
esults are di
displayed in
o flagged be
splayed in t
the Results p
9
eing
sql020071
the
sql02008
panel.
F
NfHai
_____ In thsimp
_____ Now colum
Figure 10: Wh
Note: althoufields, you cHowever, yoa SELECT stas one of the
M
e Query table SELECT *
click the Exmns in the t
hen you run a
ugh SQL Secan access aou will almotement, rat
e first things
Microsoft SQL Create an
Copyright ©
b, change th (leave the F
xecute buttable, as sho
a SELECT * q
erver initiallyall of the colst always wther than uss you should
Server featund work with © 2012, Craig
he SELECT staFROM clause
on to run thown in Figur
query, you se
y limits the umns in a L
want to explise the SELECd do to optim
ures that can a Linked Serg Pelkie, ALL
atement. Re as it is).
he revised qre 10.
ee data for all
Linked ServLinked Servecitly specifyT * query. Umize a quer
be used withrver for your RIGHTS RES
eplace the e
query. You s
ll of the colum
ver query toer table by uy the columnUsing explicry.
h the IBM i IBM i
SERVED
explicit colum
should see d
mns in the ta
o select onlyusing a SELEns that you cit column n
mn name lis
data for all o
ble.
y data in chaECT * query want to ret
names in the
10
st with a
of the
sql02009
aracter . trieve in e SELECT
CIsS
F
F
Create aIn the next sstatements tSQL Server
_____ In thData
Figure 11: Se
_____ On thnamBUTT
Figure 12: En
M
a new dseries of testhrough thedatabase an
e SQL Serveabase item,
elect the New
he New Date value. LeaTON.
nter the value
Microsoft SQL Create an
Copyright ©
atabasests, you wille linked servnd fill it with
er Managem as shown i
w Database ite
tabase dialave all of th
e SQL400 as t
Server featund work with © 2012, Craig
e in SQL create a ne
ver to your Ih data from
ment Studio,n Figure 11
em to create
og, Generahe other opt
the database
ures that can a Linked Serg Pelkie, ALL
L Serverew databaseIBM i. The S your IBM i.
, right-click .
a new SQL S
al page (Figions set to t
e name.
be used withrver for your RIGHTS RES
r e in SQL SeSQL stateme
the Databa
Server databa
ure 12), entheir default
h the IBM i IBM i
SERVED
rver. You wents will cre
ases item a
ase.
ter SQL400 ats. DO NOT
ill then run eate a table
and select th
as the DataT CLICK TH
11
SQL in the
he New
sql02010
base HE OK
sql02011
Fle
_____ Click in Fig
_____ If youSQL levelprior in the
_____ Leavedatab
Figure 13: If evel to allow
M
the Optiongure 13.
u are workinServer (SQLl of the data versions ofe SQL Serve
e all of the obase.
you work wit the new data
Microsoft SQL Create an
Copyright ©
ns item on t
ng in a mixeL Server 20abase to allof SQL Serveer Books On
other option
th SQL Serveabase to wor
Server featund work with © 2012, Craig
the New Da
ed environm05 or SQL Sow you to er. You shoul
nline before
ns set to the
r 2005 or SQrk with the pr
ures that can a Linked Serg Pelkie, ALL
atabase dia
ment of SQL Server 2000asily save ald review th changing th
eir default v
QL Server 200rior versions.
be used withrver for your RIGHTS RES
alog to displ
Server 2000), you may and restore he informatihe setting.
values. Click
00 databases,
h the IBM i IBM i
SERVED
ay the optio
08 R2 and e want to setthe new dation about co
k the OK but
s, you can set
ons page, as
arlier versiot the Comptabase ontoompatibilit
tton to crea
t the compati
12
s shown
on of atibility
o the ty level
ate the
sql02012
ibility
F
_____ You syou d
Figure 14: Yo
M
should see tdo not see t
ou can now se
Microsoft SQL Create an
Copyright ©
the new SQLthe database
ee the SQL40
Server featund work with © 2012, Craig
400 database, review th
00 database i
ures that can a Linked Serg Pelkie, ALL
se in the listhe previous
in the list of d
be used withrver for your RIGHTS RES
t of databassteps to cre
databases.
h the IBM i IBM i
SERVED
ses, as showeate the dat
wn in Figure tabase.
13
14. If
sql02013
WIc
Uf
F
Work wIn this sectiocommands i
Use a SELform a ta_____ In th
windo
_____ Enter
use Sgo selecinto from go
wherof the
For eS105H
Mana
Notewheris theServe
Figure 15: Cli
M
ith the Ion, you'll won SQL Serv
LECT INTable on yoe SQL Serveow, as show
r the followi
SQL400;
ct cusnum, SQL400.dbo linked_ser
re linked_see catalog th
example, in HMNM. Enter tagement Stu
e: when youre the table e default scher 2005, dbo
ick the New Q
Microsoft SQL Create an
Copyright ©
IBM i daork with sever that use
TO statemour IBM ier Managemwn in Figure
ng stateme
lstnam, ini.QCUST rver_name.ca
erver_name ishat is display
Figure 4 onthe correspoudio for you
u enter SQL40is created. hema and Qo was the "o
Query button
Server featund work with © 2012, Craig
atabaseveral techniqdata from y
ment to pi
ment Studio, 15 (at ).
nts into the
it, street,
atalog_name
s the name yed under t
page 6 theonding valuur linked ser
00.dbo.QCUS
dbo.QCUST isQCUST is the towner name
to open a ne
ures that can a Linked Serg Pelkie, ALL
e from Sques using tyour IBM i a
populate a
, click the N
e new query
city, stat
.ADVWORKS.Q
of your linkhe linked se
linked_seres that are rver.
ST, SQL400 iss the schemtable name.e" (it stands
ew query pan
be used withrver for your RIGHTS RES
SQL Servthe linked s
and affect da
a table in
New Query
window (at
te, zipcod
QCUSTCDT;
ked server aerver.
rver_name is displayed in
s the name oma-qualified . In versionss for "databa
nel and enter
h the IBM i IBM i
SERVED
ver server. You'lata on your
n the SQL
button to o
t )
and catalog_
M270 and thn your SQL
of the SQL S name of thes of SQL Sease owner")
r the SELECT
ll run SQL IBM i.
L400 data
open a new
_name is the
he catalog_n Server
Server datae table, whe
erver prior to).
xxxx
INTO statem
14
abase
query
name
name is
base ere dbo o SQL
sql02014
ment.
Q
Ft
_____ AfterStud
• Ifa
• Ifth
_____ Now dbo.Q
_____ Expatable
Query the d
_____ RightFigur
_____ SQL displa
Figure 16: Yothat was copi
M
r entering thio to run the
f the query ffected (cop
f the query he required
expand theQCUST, as sh
nd the dbo.e, as shown
data in the
t-click the dre 16.
Server geneaying the re
ou can now ruied from the I
Microsoft SQL Create an
Copyright ©
he statemene query.
runs succespied from yo
does not ru corrections
SQL400 dataown in Figu
QCUST table in Figure 15
e SQL400.d
bo.QCUST ta
erates the Sesults in the
un a query agIBM i to the S
Server featund work with © 2012, Craig
nts, click the
ssfully, you wour IBM i to
n successfu to the SELE
abase and eure 15 (at
and expand5.
dbo.QCUST
ble and sele
ELECT stateme Results pa
gainst the datSQL Server ta
ures that can a Linked Serg Pelkie, ALL
e Execute b
will see a m the new SQ
lly, you willECT statemen
expand Tab).
d Columns.
table
ect the Sele
ment shownnel.
ta in the SQLable.
be used withrver for your RIGHTS RES
button (at
message statQL Server ta
see one or nt and run t
les. You sh
. You should
ect Top 100
n in the que
L400.dbo.QCU
h the IBM i IBM i
SERVED
) in SQL Se
ting how maable).
r more errorthe query ag
ould see the
d see the lis
00 Rows ite
ery panel an
UST table. Yo
erver Manag
any rows we
r messages.gain.
e new table
st of column
em, as show
d runs the q
ou will see th
15
gement
ere
Make
ns in the
wn in
query,
sql02015
e data
AIpsS
Btg(S
Fe
Attempt aIn the previopopulate a tsection, youSELECT INTO
Based on thto follow thrgenerated. I(the ability tSQL Server)
_____ Open
_____ Enterof the
selecinto from
wherof the
_____ Click mess
Figure 17: Wherrors are dis
M
a SELECTous section,able in the 'll attempt t statement
e title of thirough with tIn the followto create a t).
n a new que
r the followie statement
ct cusnum, linked_ser SQL400.dbo
re linked_see catalog th
the Parse sage shown
hen you clicksplayed in the
Microsoft SQL Create an
Copyright ©
T INTO fr, you saw thSQL Server to perform tthat runs ag
s section, ythe steps shwing sectiontable on the
ry window (
ng statemet that you u
lstnam, inirver_name.ca.QCUST
erver_name ishat is display
button as s in the figur
k the Parse bue Results pan
Server featund work with © 2012, Craig
om SQL Shat you coul database, bthe reverse:gainst the S
you’ll find thown in this s, you'll use
e IBM i from
(click the Ne
nt into the nsed in the p
it, street, atalog_name
s the name yed under t
hown in Fige is displaye
utton, the SQel.
ures that can a Linked Serg Pelkie, ALL
Server told use a SELbased on a : create a taSQL Server d
at this tech section so te techniques SQL Serve
ew Query b
new query wprevious sec
city, stat.ADVWORKS.Q
of your linkhe linked se
ure 17. Theed.
QL statement(
be used withrver for your RIGHTS RES
o the IBMLECT INTO SQtable in theable in the Idatabase.
nique does that you wils that providr, then popu
button).
window. Thection to crea
te, zipcod QCUST
ked server aerver.
e SQL statem
(s) in the que
h the IBM i IBM i
SERVED
M i QL statemen IBM i databIBM i databa
not work. Hll see the erde an equivulate that ta
e statementate the table
and catalog_
ment is pars
ery window a
nt to create base. In thisase based o
However, it rrors that arvalent capabable with da
t is a mirrore in SQL Se
_name is the
sed and the
are parsed an
16
and s
on a
is useful re bility ata from
r-image rver:
name
error
sql02101
nd any
F
_____ The emaxi
_____ You mnamethe PExec
Figure 18: If
M
error messamum numb
might think e, and use aParse buttocute button,
you use a 3-p
Microsoft SQL Create an
Copyright ©
ge indicatesber of prefixe
that you coa statement n, the state, you get th
part name, y
Server featund work with © 2012, Craig
s that the lines.
ould omit the similar to t
ement will pae error mes
you get the "d
ures that can a Linked Serg Pelkie, ALL
nked server
e server_nathat shown iarse successsage shown
database doe
be used withrver for your RIGHTS RES
r database n
ame part of thin Figure 18sfully. Howen in the figu
es not exist" e
h the IBM i IBM i
SERVED
name contai
he linked se8. In this casever, when ure.
error.
ins more th
erver database, when yo you click th
17
an the
ase ou click he
sql02102
F
_____ If youOPENQ
Whenmess
Noteyou g
Figure 19: Yo
M
u search forQUERY optionn you execusage was for
e: it does noget the sam
ou cannot run
Microsoft SQL Create an
Copyright ©
r a solution n. Figure 19 ute the statermatted to s
ot matter if ye error mes
n the stateme
Server featund work with © 2012, Craig
for this prob shows an Oement, the eshow in the
you use a 4ssage.
ent by using t
ures that can a Linked Serg Pelkie, ALL
blem, you mOPENQUERY sterror messa Messages p
4-part, 3-par
the OPENQUE
be used withrver for your RIGHTS RES
may see sugtatement thaage shown inpanel for thi
rt or 2-part
ERY techniqu
h the IBM i IBM i
SERVED
ggestions abat embeds tn the figureis figure).
identifier fo
e.
bout using tthe SELECT I
e is displayed
or the INTO c
18
he INTO. d (the
clause;
sql02103
CIwi
FD
Create thIt appears thwill not worknsert into o
1. Creat
2. Use atable
_____ To geYou cSQL
_____ LocatTo, N
Figure 20: UsDDL.
M
he target hat the SELEk for a new ne operatio
te the table
an SQL INSEe.
et started, ycan use SQLServer data
te the SQL40New Query
se the Script
Microsoft SQL Create an
Copyright ©
IBM i tabECT INTO tectable on a ln, you'll see
.
ERT INTO sta
you need theL Server to gabase.
00.dbo.QCUST
y Editor Win
Table as, CRE
Server featund work with © 2012, Craig
ble, use Ichnique (whinked servee how you c
atement to g
e Data Defingenerate th
T table in anndow menu
EATE to, New
ures that can a Linked Serg Pelkie, ALL
INSERT Ihich creates er. Instead ocan split the
get data from
nition Langue DDL state
nd right-clicu items, as
w Query Edito
be used withrver for your RIGHTS RES
INTO the target tof trying to e task into tw
m the SQL S
uage (DDL) ement based
ck it. Select shown in Fi
or Window ite
h the IBM i IBM i
SERVED
table, then combine thewo steps tha
Server table
statement td on the exi
the Script gure 20.
em to genera
inserts datae table creaat will work
e into the IB
to create thisting table
Table as, C
ate the CREAT
19
a into it) te and :
BM i
he table. in the
CREATE
sql02104
TE TABLE
Fd
_____ SQL valid
Figure 21: SQdatabase.
M
Server gene statement
QL Server gen
Microsoft SQL Create an
Copyright ©
erates the sthat will cre
nerates a vali
Server featund work with © 2012, Craig
tatements seate the tab
id CREATE TA
ures that can a Linked Serg Pelkie, ALL
shown in Figle in the SQ
ABLE stateme
be used withrver for your RIGHTS RES
gure 21. TheQL Server da
ent that will c
h the IBM i IBM i
SERVED
e CREATE TAatabase.
create the tab
BLE stateme
ble in a SQL
20
ent is a
sql02105
Server
F
_____ Beca4-parparse
Figure 22: If
M
use you wart linked sere the statem
you attempt
Microsoft SQL Create an
Copyright ©
nt to createrver identifie
ment, you ge
to create the
Server featund work with © 2012, Craig
e the table oer as shownet the error
e table on the
ures that can a Linked Serg Pelkie, ALL
on your IBM n in Figure 2 about the m
e linked serve
be used withrver for your RIGHTS RES
i, you migh22 to create maximum n
er, you get an
h the IBM i IBM i
SERVED
ht think that the table. Humber of pr
n error mess
t you can enHowever, wrefixes agai
age.
21
nter the when you
n.
sql02106
F
_____ Althocan u
_____ In thwith [PRIM
Ctrl-
_____ Click
_____ Open(Edit
_____ Chan
EXEC ) at
For lpart
Noteinside
EXEC
Notenon-dEXEC
CHEC
Figure 23: Us
M
ough you cause that stat
e query winCREATE TABL
MARY] clause-C) to copy t
the New Q
n a new quet, Paste or
nge the state
('CREATE TAcusnum nulstnam vainit vastreet vacity vastate vazipcod nu
linked_ser
linked_serve
of the name
e: the EXEC se those pare
('somethin
e: if library Adefault data (‘CREATE TA
CK YOUR S
se the EXEC s
Microsoft SQL Create an
Copyright ©
n't run the Ctement as t
ndow shownLE down throe). When thethe stateme
Query butto
ry window aCtrl-V).
ement so th
ABLE ADVWORumeric (6, archar (8) archar (3) archar (13)archar (6) archar (2) umeric (5, rver_name;
er_name, sube, as shown
statement uentheses is
g_to_do') a
ADVWORKS is iabase), enteABLE catalo
SYNTAX!
statement to
Server featund work with © 2012, Craig
CREATE TABL
he basis for
in Figure 2ough the cloe statementent.
n to open a
and paste th
hat it looks l
RKS.QCUST ( 0) NOT NULL NOT NULL NOT NULL NOT NULL NOT NULL NOT NULL0) NOT NULL
bstitute the in the figur
uses opening embedded
at linked_se
in a non-defer a 3-part iog_name.ADVW
perform a pa
ures that can a Linked Serg Pelkie, ALL
LE statemenr another sta
2, use yourosing right pt is selected
new query
he CREATE TA
ike the follo
L, L, L, L, L, L, L)'
name of there).
g and closinwithin open
erver_name;
fault ASP ondentifier forWORKS.QCUST
ass-through o
be used withrver for your RIGHTS RES
t that was gatement tha
r mouse to sparenthesis d, use the Ed
window.
ABLE statem
owing, as sh
e linked ser
g parenthesning and clos
n your IBM r the table nT (
operation to t
h the IBM i IBM i
SERVED
generated bat will run o
select all of character (dit, Copy m
ment that yo
hown in Figu
rver to your
ses charactesing single-
i (in SQL Sename:
the linked ser
by SQL Servon your IBM
the code st(on the ON menu item (
ou copied int
ure 23:
IBM i (only
ers, and evequote chara
erver terms,
rver.
22
ver, you i.
arting
or press
to it
y the first
erything acters:
, in a
sql02107
F
F
_____ Click comp
_____ If thesucce
_____ If themessstandyou a
Figure 24: Wh
_____ To enProp
Figure 25: Rig
M
the Parse plete succe
e parse repoessfully.
e parse is susage shown ds for Remoare trying to
hen you click
nable RPC foperties item
ght-click the
Microsoft SQL Create an
Copyright ©
button to paessfully me
orts any erro
uccessful, cl in Figure 24ote Proceduro run in SQL
k the Execute
or the linkedm, as shown
linked server
Server featund work with © 2012, Craig
arse the EXEessage, as s
ors, correct
ick the Exe4 (Server 'lire Call. It neL Server.
button, you
d server, rig in Figure 2
r name and s
ures that can a Linked Serg Pelkie, ALL
EC statemenshown in Fig
the statem
ecute buttoninked_serveeeds to be e
get the error
ght-click the5.
select the Pro
be used withrver for your RIGHTS RES
nt. You shougure 23.
ent until yo
n. The resuler_name' is enabled to s
r message sh
e linked serv
operties item.
h the IBM i IBM i
SERVED
uld see the C
ou can get it
lts panel disnot configu
support the
hown here.
ver name an
Command(
t to parse
splays the ered for RPCEXEC statem
nd select the
23
(s)
rror .). RPC
ment that
sql021071
e
sql021072
F
_____ On th
_____ Click selecOut
_____ Click
Figure 26: In
_____ Back is themess
(0 ro
_____ Go toADVWO
_____ If youneces
M
he Linked Se
the RPC Octor and seleproperty, n
the OK but
the Server O
in SQL Serve current wisage if the c
ow(s) affec
o a 5250 coORKS library
u do not seessary.
Microsoft SQL Create an
Copyright ©
erver Prope
ut propertyect the valuenot the RPC
tton to close
Options page,
ver Managendow. Click
command ru
ted)
mmand enton your IBM
e file ADVWOR
Server featund work with © 2012, Craig
rties dialog
y. A drop-doe True fromC property
e the Linked
, set the RPC
ement Studiok the Execuuns successf
ry line and M i. You sho
RKS/QCUST, re
ures that can a Linked Serg Pelkie, ALL
(Figure 26)
wn list selecm the list thay.
d Server Pro
C Out value to
o, be sure tte button. Tfully:
run a DSPLIBould see the
eview the st
be used withrver for your RIGHTS RES
), click the S
ctor will appat appears.
operties dial
o True.
the query wThe results
B command new file QC
teps shown
h the IBM i IBM i
SERVED
Server Opt
pear. Click t Be sure yo
og.
indow with panel will sh
to display tUST in the li
above and
tions item.
the drop-dowou select th
the EXEC stahow the foll
the contentbrary.
rerun them
24
wn he RPC
sql021073
atement owing
s of the
m as
Fy
_____ If youcommtypes
DSPFF
_____ OpenFigur
INSER (
SELEC FROM
wherof the
Figure 27: Enyour IBM i.
_____ Click repor
_____ Click repor
M
u see file ADmand to views and length
FD ADVWORKS
n a new quere 27:
RT INTO lin(cusnum, lsCT cusnum, SQL400.dbo
re linked_see catalog th
nter the INSE
the Parse rted.
the Executrting the nu
Microsoft SQL Create an
Copyright ©
DVWORKS/QCUS
w the field dhs that corre
/QCUST
ry window a
nked_server_tnam, init,lstnam, ini
o.QCUST
erver_name ishat is display
ERT INTO stat
button to pa
te button tomber of row
Server featund work with © 2012, Craig
ST on your Idefinitions felate with th
and enter th
_name.catalo street, ciit, street,
s the name yed under t
tement to sel
arse the INS
o run the INw affected, a
ures that can a Linked Serg Pelkie, ALL
IBM i, use thfor the file. Yhe CREATE TA
he following
og_name.ADVity, state, city, stat
of your linkhe linked se
lect data from
SERT INTO st
SERT INTO sas shown in
be used withrver for your RIGHTS RES
he Display FYou should ABLE statem
INSERT INT
VWORKS.QCUST zipcod) te, zipcod
ked server aerver.
m SQL Server
tatement. C
tatement. Y Figure 27.
h the IBM i IBM i
SERVED
File Field Desee the field
ment.
TO statemen
T
and catalog_
r and insert it
Correct any e
You should s
escription (Dd names, da
t, as shown
_name is the
t into the tab
errors that a
see a messa
25
DSPFFD) ata
n in
name
sql02108
ble on
are
age
FN
_____ On a
DSPPF
_____ Presswill s
Figure 28: ThNote the 2-by
_____ As yofield fieldsstate
M
5250 comm
FM ADVWORKS
s F10 to dissee the data
he QCUST tabyte length fie
ou can see ithat indicat
s was defineement that w
Microsoft SQL Create an
Copyright ©
mand, enter
/QCUST
splay hexade displayed a
ble, displayedlds that prece
n Figure 28es the num
ed as a varcwas generat
Server featund work with © 2012, Craig
r the followin
ecimal data,as shown in
d using the heede each of t
, each of thber of byteshar field typted by SQL S
ures that can a Linked Serg Pelkie, ALL
ng Display P
, then F11 t Figure 28.
exadecimal othe character
e characters in the fieldpe (see FiguServer).
be used withrver for your RIGHTS RES
Physical File
to display th
ver-and-under fields.
r fields is pred. This is beure 23, whe
h the IBM i IBM i
SERVED
e Member co
he over-and
er view of th
eceded by aecause each re you use t
ommand (DS
d-under disp
e DSPPFM co
a 2-byte "len of the charthe CREATE T
26
SPPFM):
play. You
sql02109
ommand.
ngth" racter TABLE
RTt
TE
Io
Fa
_____ If youReturtypesstate
_____ If youAfterof ADV
Run an SThe INSERT to run the tw
To run DDL EXEC statem
In this sectioon your IBM
_____ On yonameSyste
Figure 29: Yoalternative to
M
u do not warn to the SQs to the chaement as it i
u change thr you recreaVWORKS/QCUS
QL UPDAINTO statemwo other SQ
statements ent.
on, you'll ruM i.
our PC, opee, then Schem i Naviga
ou can use the the STRSQL
Microsoft SQL Create an
Copyright ©
ant to work wQL CREATE TAr data type.s.
he data typete table, runST with the D
ATE statement that yoQL Data Man
(such as CR
un an UPDATE
en the Systeemas. In Ftor, the sys
e System i N command en
Server featund work with © 2012, Craig
with varchaABLE statem. You can le
e, run the EXn the INSERTDSPPFM comm
ment froou ran in thenipulation La
REATE TABLE)
E statement
em i Navigatigure 29 the
stem name w
Navigator to vnvironment.
ures that can a Linked Serg Pelkie, ALL
r fields on yment (Figure
ave all of th
XEC statemeT INTO statemand.
m SQL See preceding anguage (DM
), you need
in SQL Serv
tor. Expand e system nawill be differ
view the conte
be used withrver for your RIGHTS RES
your IBM i, d 23) and ch
he remaining
nt again to ement again
erver to t section shoML) stateme
to encode t
ver that affe
the Databaame is showrent.
ents of a data
h the IBM i IBM i
SERVED
delete file Ahange each og code in th
recreate filen, then revie
the IBM ows a patterents: UPDATE
those statem
ects the ADV
ases item, wn as S105H
abase file. Us
ADVWORKS/QCU
of the varchhe CREATE TA
e ADVWORKS/Qew the new
i rn that you cE and DELET
ments withi
VWORKS/QCUST
then the syHmnm. On y
se this as an
27
UST. har data ABLE
QCUST. version
can use E.
n an
T table
stem your
sql02016
F
F
_____ If youSche
Figure 30: Rig
_____ In thclick the O
Figure 31: En
M
u do not seeemas item a
ght-click the
e Select Schthe Add bu
OK button to
nter the schem
Microsoft SQL Create an
Copyright ©
e the ADVWORand click the
Schemas item
hemas to Dutton. You sho close the d
ma name AD
Server featund work with © 2012, Craig
RKS schema e Select Sc
m, click the S
isplay dialoghould see ADdialog and r
VWORKS and
ures that can a Linked Serg Pelkie, ALL
(library) in chemas to D
Select Schem
g (Figure 31DVWORKS addreturn to the
d click the Ad
be used withrver for your RIGHTS RES
the list of sDisplay ite
mas to Display
1), enter theded to the lise System i N
dd button.
h the IBM i IBM i
SERVED
schemas, rigm, as show
y item.
e schema nast of selecteNavigator.
ght-click then in Figure
ame ADVWORKed schemas
28
e 30.
sql020161
KS and . Click
sql020162
F
F
_____ Back as sh
Figure 32: Ex
_____ Right
Figure 33: Rig
M
in the Systhown in Figu
xpand the AD
t-click the Q
ght-click the
Microsoft SQL Create an
Copyright ©
em i Navigaure 32. You
VWORKS sch
QCUST table
QCUST table
Server featund work with © 2012, Craig
ator, expandshould see
hema and clic
e and select
e and select th
ures that can a Linked Serg Pelkie, ALL
d the ADVWthe list of ta
ck the Tables
t the View C
he View Cont
be used withrver for your RIGHTS RES
WORKS scheables that a
item.
Contents it
tents item.
h the IBM i IBM i
SERVED
ema and cliare within th
tem, as show
ck the Tablhe schema.
wn in Figure
29
les item,
sql020163
e 33.
sql020164
F
F
_____ The Cneed
Figure 34: Th
_____ Now
_____ Enter
UPDATset cwhere
wherof the
_____ Click
_____ Click row w
_____ Go baopen
_____ Use tthe ACUSNU
Figure 35: Ve
M
Contents o to resize th
he Contents o
go back to
r the followi
TE linked_scity='PARISe cusnum=93
re linked_see catalog th
the Parse
the Executwas affected
ack to the Sed.
the View CoADVWORKSUM value tha
erify that the
Microsoft SQL Create an
Copyright ©
of ADVWORhe window t
of window sho
the SQL Ser
ng SQL UPDA
server_name.' 8472
erver_name ishat is display
button to pa
te button tod.
System i Nav
ontents iteS.QCUST taat you specif
CITY value w
Server featund work with © 2012, Craig
RKS.QCUSTto see all of
ows the data
rver Manage
ATE stateme
.catalog_nam
s the name yed under t
arse the UPD
o run the sta
vigator. Clo
m as shownable. You shfied, as show
was changed
ures that can a Linked Serg Pelkie, ALL
T window op the rows an
that is in the
ement Cons
ent into the
ame.ADVWORKS
of your linkhe linked se
DATE statem
atement. Yo
se the Cont
n in Figure 3ould see thawn in Figure
for the select
be used withrver for your RIGHTS RES
pens, as shond columns
e table.
sole and ope
new query
S.QCUST
ked server aerver.
ent. Correct
ou should ge
tents of wi
33 to open aat the CITY e 35.
ted customer
h the IBM i IBM i
SERVED
own in Figur of data.
en a new qu
window:
and catalog_
t any errors
et a messag
ndow that y
a new Contvalue was c
r.
re 34. You m
uery window
_name is the
s that are re
ge reporting
you previous
ents of winchanged for
30
may
sql02017
w.
name
eported.
that 1
sly
ndow for the
sql02019
31 Microsoft SQL Server features that can be used with the IBM i
Create and work with a Linked Server for your IBM i Copyright © 2012, Craig Pelkie, ALL RIGHTS RESERVED
Run an SQL DELETE statement from SQL Server to the IBM i To finish out your tests of using DML statements from SQL Server to your IBM i, you will run an SQL DELETE statement.
_____ Go back to the SQL Server Management Console and open a new query window.
_____ Enter the following SQL DELETE statement into the new query window:
DELETE FROM linked_server_name.catalog_name.ADVWORKS.QCUST where cusnum=938472
where linked_server_name is the name of your linked server and catalog_name is the name of the catalog that is displayed under the linked server.
_____ Click the Parse button to parse the DELETE statement. Correct any errors that are reported.
_____ Click the Execute button to run the statement. You should get a message reporting that 1 row was affected.
_____ Go back to the System i Navigator. Close the Contents of window that you previously opened.
_____ Use the View Contents item as shown in Figure 33 to open a new Contents of window for the ADVWORKS.QCUST table. You should see that the row that you specified for deletion is no longer in the table.
32 Microsoft SQL Server features that can be used with the IBM i
Create and work with a Linked Server for your IBM i Copyright © 2012, Craig Pelkie, ALL RIGHTS RESERVED
Work with a batch of SQL statements Although it is useful to be able to enter and run statements in the SQL Server Management Studio, it is unlikely that you will always want to enter and run statements manually. It is more likely that you will want to save previously written SQL statements so that you can easily run them again.
Create a T-SQL batch script In this section, you'll create a batch of Transact SQL (T-SQL) statements. T-SQL is the name Microsoft uses for their SQL language environment. "Batch" in this sense simply means one or more T-SQL statements that are run, it does not imply batch processing as in the IBM i environment.
_____ In the SQL Server Management Studio, open a new query window.
_____ Enter the following sequence of T-SQL statements into the query window. Pay particular attention to the use of semicolons at the end of each T-SQL statement. Do not enter a semicolon after the "go" commands.
EXEC ('DROP TABLE ADVWORKS.QCUST') at linked_server_name; go EXEC ('CREATE TABLE ADVWORKS.QCUST ( cusnum numeric (6, 0) NOT NULL, lstnam char (8) NOT NULL, init char (3) NOT NULL, street char (13) NOT NULL, city char (6) NOT NULL, state char (2) NOT NULL, zipcod numeric (5, 0) NOT NULL)' ) at linked_server_name; go INSERT INTO linked_server_name.catalog_name.ADVWORKS.QCUST (cusnum, lstnam, init, street, city, state, zipcod) SELECT cusnum, lstnam, init, street, city, state, zipcod FROM SQL400.dbo.QCUST; go
where linked_server_name is the name of your linked server and catalog_name is the name of the catalog that is displayed under the linked server.
_____ Click the Parse button to validate the batch. You should see a Command(s) completed successfully message, as shown in Figure 36. If there are any errors in the batch, correct them and run the Parse again.
F
Figure 36: Th
_____ Now was s
_____ Usingcommthe d
M
his shows the
click the Exsuccessfully
g either the mand, verifydata from yo
Microsoft SQL Create an
Copyright ©
T-SQL batch
xecute butty completed
System i Ny the contenour SQL400.d
Server featund work with © 2012, Craig
h with the thr
on. You sho.
avigator Vients of the ADdbo.QCUST ta
ures that can a Linked Serg Pelkie, ALL
ree statemen
ould get thre
ew ContenDVWORKS/QCUS
able on SQL
be used withrver for your RIGHTS RES
ts and the GO
ee message
nts techniquST table on
L Server.
h the IBM i IBM i
SERVED
O command.
es, indicating
ue (Figure 33 your IBM i.
g that each
3) or the DS It should co
33
sql02121
step
SPPFM ontain
S
F
F
Save the _____ Now
_____ Creatcreatuse t
_____ In SQbatch
_____ Use tcurrethat It do
Figure 37: Us
_____ A conwill bexamcrypa scrbatch
Figure 38: En
_____ Click Manathat y
M
T-SQL bathat you've
te a directorte. The directhat director
QL Server Mh is the curr
the File, Saent query wishown in thes not matt
se the File, Sa
nventional Sbe using for mple is Load_tic name foipt file baseh files is .sq
nter a name f
the Save bagement Stuyou assigne
Microsoft SQL Create an
Copyright ©
atch scrip coded and
ry on your Pctory that isry name or a
Managementrently select
ave As... meindow. Notee figure, de
ter what the
ave As... men
Save File As saved scrip_ADVWORKS_Q
or a script.ed upon the ql. Use that
for your scrip
button to savudio, you wied to the sav
Server featund work with © 2012, Craig
pt tested the T
PC where yos shown in tany other n
t Studio, be ted query w
enu item ase: the nameepending upe name of th
nu item to sa
dialog is dipts. Enter a CUST.sql. T. The idea is name you a extension.
t. Use the file
ve the T-SQill see that tved script fi
ures that can a Linked Serg Pelkie, ALL
T-SQL batch
ou can save he exampleame of you
sure that thindow.
shown in Fe shown in ton the nam
he tab is.
ave your T-SQ
splayed (Figfile name fohere is no s that you wassign to it.
e name exten
QL batch filethe tab on tle.
be used withrver for your RIGHTS RES
h, you can s
T-SQL batces in this cour choosing.
he query wi
Figure 37 to the Save As
me of the que
QL script file.
gure 38). Naor the saved particular
want to be a The conven
nsion .sql.
e. When youthe query w
h the IBM i IBM i
SERVED
save it.
ches ("scripturse is c:\S
ndow conta
save the cos menu itemery window
avigate to td script. The benefit to
able to recogntional file e
u return to tindow now d
ts") that yoQLScripts. Y
ining your T
ontents of thm will vary f (shown in t
he directorye name usedo using a shgnize the fuextension fo
the SQL Servdisplays the
34
u You can
T-SQL
he from the tab).
sql02122
y you d in the hort, nction of
or T-SQL
sql02123
ver e name
Fs
F
_____ In thbatch
_____ In thshow
_____ You csave
Figure 39: Cliscript.
_____ In thFigur
Figure 40: Us
_____ Navigit loabutto
M
e SQL Serveh that you ju
e upper righwn in Figure
can also clos the content
ick the Close
e SQL Servere 40.
se the File, Op
gate to the ded into a q
on to run it a
Microsoft SQL Create an
Copyright ©
er Managemust saved.
ht corner of 39.
se the otherts of those w
button in the
er Managem
pen, File... m
directory whquery windoagain.
Server featund work with © 2012, Craig
ment Studio,
the query w
r open querwindows, yo
e upper-right
ment Studio,
menu item to
here you saow. Once it
ures that can a Linked Serg Pelkie, ALL
, be sure th
window, loc
y windows iou can accep
t corner of the
, use the Fi
open your sa
ved your T-is in the que
be used withrver for your RIGHTS RES
at the curre
ate and clic
if you want pt or reject
e query wind
le, Open, F
aved .sql scrip
-SQL script ery window,
h the IBM i IBM i
SERVED
ent query w
ck the close
to. When y the offer to
dow to close t
File menu it
pt file.
file and ope, you can cl
indow conta
icon (the "X
ou are promo save.
the window fo
tem as show
en it. You shick the Exe
35
ains the
X"), as
mpted to
sql02124
for the
wn in
sql02125
hould see cute
RYfTwi
SPo
F
Run the TYou now havfile name exThe file openwithin the Mndependent
SQL Server Prompt enviopening the
_____ On yogroup
_____ Enter
_____ You s
_____ If youcomm
Figure 41: If
_____ If yousteps
M
T-SQL bave a T-SQL xtension .sqns in SQL Se
Managementtly of the Ma
provides theronment. W Manageme
our PC, opep).
r the followi
sqlcmd
should see t
u get the 1>mand.
the SQLCMD
u did not ges shown on
Microsoft SQL Create an
Copyright ©
tch file frbatch file thl for the baerver Managt Studio, it wanagement
e sqlcmd comWhen you us
nt Studio.
en a Window
ng comman
the 1> comm
> command
command ru
et the commthe next pa
Server featund work with © 2012, Craig
rom a Wihat is savedatch file, yougement Stuwould be moStudio.
mmand to ise sqlcmd, yo
ws Command
nd in the Co
mand promp
prompt, ent
uns, you will g
mand prompge.
ures that can a Linked Serg Pelkie, ALL
indows C to a directou can doubledio. Althougore useful to
nteract withou can run c
d Prompt wi
mmand Pro
pt as shown
ter the word
get the prom
t when you
be used withrver for your RIGHTS RES
Commandory on your e-click on thgh you can o be able to
h SQL Servecommands
indow (it is
ompt window
in Figure 4
d exit and p
mpt as shown
entered the
h the IBM i IBM i
SERVED
d Prompt PC. If you uhe file in Wialways run
o run the T-S
er from the and T-SQL
in the Acce
w:
1.
press Enter
in this figure
e sqlcmd com
used the sundows Explthe batch fiSQL batch f
Windows Cobatches wit
essories pr
r to end the
e.
mmand, use
36
ggested orer. ile from file
ommand hout
ogram
sqlcmd
sql02131
e the
F
F
_____ To ruinstaQuer
_____ In th
selecselec
_____ You sof thevalue
Figure 42: Yo
_____ (SQLthe S
sqlcm
sqlcm
Figure 43: Us
M
un the sqlcmnce name. Try button to
e query pan
ct @@SERVERct SERVERPR
should see te SQL Servee SQLEXPRESS
ou can view th
L Server ExpSQLCMD comm
md –S serve
md –S \inst
se the -S para
Microsoft SQL Create an
Copyright ©
md commandTo view thoo open a new
nel, enter th
NAME; OPERTY('Ins
two results er, specifiedS which is th
he Server Na
press) Now tmand as sho
r_name\inst
ance_name
ameter to spe
Server featund work with © 2012, Craig
d you may nse names, gw query edi
he following
stanceName')
panels as shd as server_he name of
me and Insta
that you knoown in Figur
tance_name
sql0
ecify the serv
ures that can a Linked Serg Pelkie, ALL
need to specgo to the Mating panel.
statements
);
hown in Figu_name\instan
the SQL Se
ance Name in
ow the servre 43:
021321
ver_name\ins
be used withrver for your RIGHTS RES
cify the namanagement
s, then click
ure 42. The nce_name. Thrver instanc
n the Manage
ver name an
stance_name
h the IBM i IBM i
SERVED
me of your S Studio and
the Execut
top panel che bottom pce.
ement Studio
nd instance
e or just the \
SQL Server a click the Ne
te button:
contains thepanel contai
o.
name, try r
\instance_nam
37
and its ew
e name ns the
sql02132
unning
sql021322
me.
F
_____ (SQLis NU44.
Figure 44: Us
_____ The sfor th
wher
-S ide
-i ide
c:\sc
M
L Server EvaULL, enter th
se the -S para
sqlcmd commhe command
sqlcmd -S
re
entifies the
server_na
ar
instance_
ar
entifies the The -i is
cript_file_
Microsoft SQL Create an
Copyright ©
aluation Edithe server na
ameter and s
mand can bed is:
S server_na
following va
ame is the nare to be run
_name is the re to be run
following va case-sensit
name.sql is
Server featund work with © 2012, Craig
tion) If the vame as the v
specify the se
e used to ru
me\instance
alues as the
ame of the S
instance of.
alue as the tive, you mu
the complet
ures that can a Linked Serg Pelkie, ALL
value for thevalue follow
erver_name.
un the T-SQ
e_name -i c
e server nam
SQL Server
f the SQL Se
name of theust enter it a
te path and
be used withrver for your RIGHTS RES
e Instance Nwing the –S
QL batch file
:\script_fi
me and insta
where the T
erver where
e input file (as -i
file name o
h the IBM i IBM i
SERVED
Name panelparameter,
that you cr
ile_name.sq
ance name
T-SQL state
e the T-SQL
(the T-SQL
of the T-SQL
l shown in F as shown in
s
reated. The
l
ements
statements
batch file).
L batch file
38
Figure 42 n Figure
sql0213221
syntax
Fin
Fn
Ft
_____ Enter
FigurFigur
Noteparamchara
Figure 45: Thnstance nam
Figure 46: Thname and the
Figure 47: Ththe server na
M
r the sqlcmd
re 45 and Fire 47 is an e
e: if your SQmeter. Just acter, as sho
his is an exame.
his is an exame instance na
his is an examme.
Microsoft SQL Create an
Copyright ©
d command
gure 46 areexample of r
QL Server in enter the –own in Figu
mple of runnin
mple of runninme.
mple of runnin
Server featund work with © 2012, Craig
to run the T
e examples orunning the
stance namS parametere 47.
ng the SQLCM
ng the SQLCM
ng the SQLCM
ures that can a Linked Serg Pelkie, ALL
T-SQL batch
of running t command i
me is NULL, dr and the se
MD command
MD command
MD command
be used withrver for your RIGHTS RES
h file.
the commanin SQL Serv
o not speciferver name,
d in SQL Serv
d in SQL Serv
d in SQL Serv
h the IBM i IBM i
SERVED
nd in SQL Sever Evaluatio
fy it for the , without a l
ver Express, u
ver Express, u
ver Evaluation
erver Expreon Edition.
server namleading or tr
using just the
using the ser
n Edition, usi
39
ess.
me railing \
sql021323
e
sql021324
rver
sql021325
ing just
Ft
_____ Figurdoes
The efile. Aproce
Afterfile A
Do no
Figure 48: Ththe IBM i.
M
re 48 shows not already
error messaAlthough theessed.
r the commaDVWORKS/QCU
ot delete file
his shows the
Microsoft SQL Create an
Copyright ©
s the resultsy exist on th
ges are dispe errors are
and completUST is on you
e ADVWORKS/
results of ru
Server featund work with © 2012, Craig
of running he IBM i.
played becae displayed,
tes its execuur IBM i and
QCUST.
unning the T-S
ures that can a Linked Serg Pelkie, ALL
the T-SQL b
ause of the D the remain
ution, go to d that it has
SQL batch file
be used withrver for your RIGHTS RES
batch file w
DROP TABLE sing stateme
a 5250 coms data in it.
e when the A
h the IBM i IBM i
SERVED
hen the ADV
statement inents in the T
mmand prom
ADVWORKS/Q
VWORKS/QCUST
n the T-SQLT-SQL batch
mpt and ver
QCUST file is
40
T file
L batch h file are
rify that
sql02133
not on
FI
SYMu
YcT
Iai
_____ Now the ccomm
Figure 49: ThIBM i.
SummaryYou've now Managemenusing the sq
You can usecan use the T-SQL batch
If you are usanother edits used to sc
M
run the sqlcommand). Tmand result
his shows the
y seen how yt Studio. Yolcmd comma
the sqlcmd Windows Sch file using t
sing the SQtion of SQL Schedule and
Microsoft SQL Create an
Copyright ©
cmd commaThis time, bs as shown
results of ru
ou can deveou've also seand.
command wcheduled Tathe sqlcmd c
L Server ExServer, you run the sta
Server featund work with © 2012, Craig
nd again (pbecause the in Figure 49
unning the T-S
elop and teseen that you
with other pasks programcommand on
xpress editio can continu
atements th
ures that can a Linked Serg Pelkie, ALL
ress the up- ADVWORKS/QC9.
SQL batch file
st a batch ofu can save t
programs thm (in the Con a schedule
on, you are ue with the at are in the
be used withrver for your RIGHTS RES
-arrow key CUST file is o
e when the A
f T-SQL statthe T-SQL b
at are availontrol Panele.
now done w next sectioe T-SQL bat
h the IBM i IBM i
SERVED
on your keyon your IBM
ADVWORKS/Q
tements usibatch file to
able to youl program g
with this labn, where thtch file.
yboard to reM i, you see
QCUST file is
ing the your PC an
. For examproup) to run
. If you are e SQL Serv
41
epeat the
sql02134
on the
d run it
ple, you n the
using er Agent
Cs
NTRt
Tb
ItsS
Tc
D
Fis
Create aschedul
Note: the stThe ExpressR2 include tthrough the
The SQL Serbut it canno
In addition tthe SQLCMD cscheduled bScheduler to
There are a code that yo
Determin_____ Open
_____ Click Serv
_____ If thethat t
Figure 50: Gos "running".
M
a SQL See
teps shown s Edition doehe SQL Serv remaining s
rver Agent dt be configu
to saving thcommand, yatch job. Ino start a job
number of sou develope
ne if the Sn the SQL Se
the SQL Sever Agent, a
e state of ththe Agent s
o to the SQL S
Microsoft SQL Create an
Copyright ©
erver Ag
in this sectes not includver Agent. Isteps in this
does appearured to start
e T-SQL batyou can crea comparison
b in a batch
steps you nd as the bas
SQL Serverver Config
erver Servias shown in
he Agent is State is repo
Server Config
Server featund work with © 2012, Craig
gent job
ion cannot de the SQL If you are us lab, but yo
r in the Sql t in the SQL
tch file and ate a SQL Sen with an IBsubsystem.
eed to comsis of the Ag
er Agentguration Ma
ices item onn Figure 50.
Stopped, rirted as Run
guration Man
ures that can a Linked Serg Pelkie, ALL
b to run
be used wServer Agensing SQL Seou will not b
Server ConfL Server Exp
running it inerver AgentBM i, an Age
plete to creagent job.
t is runninnager progr
n the left pa
ight-click thnning.
ager and loca
be used withrver for your RIGHTS RES
n the IN
with the SQnt. All othererver Expresbe able to pe
figuration Mpress Edition
n SQL Servet job. An Ageent job is sim
ate an Agen
ng ram.
anel. In the
e Agent and
ate the SQL S
h the IBM i IBM i
SERVED
SERT IN
QL Server Er editions ofss Edition, yerform them
Manager as sn.
er Management job is esmilar to usin
nt job. You w
right panel
d click the S
Server Agent
NTO on
Express Edif SQL Serveyou can readm.
shown in Fig
ment Studio ssentially a ng the Job
will use the
, locate the
Start item. V
t. Verify that
42
a
ition. r 2008 d
gure 42
or with
T-SQL
SQL
Verify
sql02201
its state
Ntr
F
Note: if the the start morebooted.
_____ To seitem.
_____ In th
_____ Click list a
_____ VerifyConfi
Figure 51: Yo
_____ You c
M
Start Modode to Auto
et the Agent.
e SQL Serve
in the Starnd click the
y that the Aiguration Ma
ou may want
can close th
Microsoft SQL Create an
Copyright ©
e of the Agematic. Tha
t to start au
er Agent Pro
rt Mode opt Apply butt
Agent Start Manager.
to consider s
e SQL Serve
Server featund work with © 2012, Craig
ent is Manut way, the A
tomatically,
operties dia
tions; a dropton, then th
Mode is now
setting the Ag
er Configura
ures that can a Linked Serg Pelkie, ALL
ual (see FigAgent will be
, right-click
log (Figure
p-down list e OK butto
w shown as
gent start mo
ation Manag
be used withrver for your RIGHTS RES
ure 50), yoe automatic
the Agent
51), click th
will appear.n.
Automatic
ode to Autom
ger dialog o
h the IBM i IBM i
SERVED
u may wantcally started
and select t
he Service
. Select Aut
c in the SQL
atic.
nce the Age
t to consided when the P
the Propert
tab.
tomatic fro
L Server
ent is runnin
43
r setting PC is
ties
om the
sql02202
ng.
C
F
F
Create a _____ In th
item,
_____ Right
Figure 52: Rig
_____ The J
_____ On thNOT IN T
Figure 53: En
M
new Agee SQL Serve, then expan
t-click the J
ght-click on t
Job Properti
he General CLICK THEHIS SECTI
nter the Name
Microsoft SQL Create an
Copyright ©
ent job er Managemnd the Jobs
obs item an
the SQL Serv
es dialog sh
page, enteE OK BUTTON.
e and Descrip
Server featund work with © 2012, Craig
ment Studio s item.
nd select the
er Agent Jobs
hown in Figu
r Name andTON IN THI
ption for the A
ures that can a Linked Serg Pelkie, ALL
Object Exp
e New Job
s item, the cl
ure 53 is dis
d DescriptiIS DIALOG
Agent job. Cl
be used withrver for your RIGHTS RES
lorer, expan
item, as sh
lick the New
splayed.
ion for the j UNTIL INS
lick the selec
h the IBM i IBM i
SERVED
nd the SQL
hown in Figu
Job item.
job, as showSTRUCTED
ctor button fo
Server Ag
ure 52.
wn in Figure TO DO SO
or the Owner
44
ent
sql02205
e 53. DO O LATER
sql02211
item.
F
F
F
_____ You sdots 54 is
_____ In th
Figure 54: In
_____ In thin theyou s
Figure 55: In
_____ You aadde
Figure 56: Ve
M
should still bon it) that i displayed.
e Select Log
the Select Lo
e Browse foe figure. Clicsee on your
the Browse f
are returnedd to the nam
erify that the
Microsoft SQL Create an
Copyright ©
be on the Gs to the righ
gin dialog, c
ogin dialog, c
or Objects dck the OK b system will
for Objects d
d to the Seleme list, as s
SYSTEM acco
Server featund work with © 2012, Craig
eneral paght of the Ow
click the Bro
click the Brow
ialog (Figurbutton after l be differen
dialog, select
ect Login diashown in the
ount is return
ures that can a Linked Serg Pelkie, ALL
e. Click the wner item.
owse butto
wse button.
e 55), selec selecting thnt from the
the SYSTEM
alog (Figuree figure. Clic
ned to the Se
be used withrver for your RIGHTS RES
"selector" b The Select
n.
ct (check) thhe account. list shown in
account.
e 56). You sck the OK b
elect Login dia
h the IBM i IBM i
SERVED
button (the Login dialog
he SYSTEM Note: the n the figure
should see tbutton.
alog.
button withg shown in F
account, aslist of objec
e.
he SYSTEM
45
h three Figure
sql02212
s shown cts that
sql02213
account
sql02214
F
F
_____ If theaccou
Figure 57: If
_____ You sas th
Figure 58: Ve
M
e Multiple Ount and click
you see this
should be ree value for
erify that the
Microsoft SQL Create an
Copyright ©
bjects Founk the OK bu
dialog, check
eturned to tthe Owner
SYSTEM acco
Server featund work with © 2012, Craig
d dialog shoutton.
k the SYSTEM
he Generalr of the job.
ount is now s
ures that can a Linked Serg Pelkie, ALL
own in Figur
M account obj
l page. Verif DO NOT C
set as the ow
be used withrver for your RIGHTS RES
re 57 is disp
ject and click
fy that the SLICK THE O
wner of the Ag
h the IBM i IBM i
SERVED
played, chec
k the OK butto
SYSTEM accOK BUTTON
gent job.
ck the SYST
on.
count is nowN.
46
TEM
sql02215
w shown
sql02216
F
_____ In th59 is
_____ Click
Figure 59: Se
M
e Select a displayed.
the New b
elect the Step
Microsoft SQL Create an
Copyright ©
page sectio
utton to def
ps item, then
Server featund work with © 2012, Craig
on, click the
fine the first
click the New
ures that can a Linked Serg Pelkie, ALL
e Steps item
t step in the
w button.
be used withrver for your RIGHTS RES
m. The Job s
e job.
h the IBM i IBM i
SERVED
step list pag
ge shown in
47
Figure
sql02220
E
F
Enter Gene
_____ On thStep
Type
Com
(all o
_____ WhenCLIC
_____ Click
Notenot pEXEC.and
Figure 60: Se
M
eral values
he General p name
e
mmand
other values)
n done enteCK THE OK
the Parse
e: when youparsed. You If your Agcarefully r
et the Genera
Microsoft SQL Create an
Copyright ©
for Agent
page, ente
Drop
Trans
EXEC
wherethat y
) (leav
ering the val BUTTON.
button to va
u enter an EXu need to begent job eneview the
al values for S
Server featund work with © 2012, Craig
Job Step 1
r the followi
(delete) AD
sact-SQL sc
('DROP TABL
e linked_seyou defined
e set to the
lues, the Ge
alidate the c
XEC statemee especially nds in erro code that y
Step 1 of the
ures that can a Linked Serg Pelkie, ALL
1
ing values f
DVWORKS/QCU
ript (T-SQL)
LE ADVWORKS
erver_name is earlier.
ir default va
eneral page
command st
ent, the text careful to er, you musyou entere
Agent job.
be used withrver for your RIGHTS RES
for the first
UST
)
S.QCUST') at
s the name
alues)
e should loo
tatements t
t that is encenter a validst come baed for each
h the IBM i IBM i
SERVED
step of the
t linked_se
of the linke
ok like Figure
that you ent
closed withind SQL statemack to eachh EXEC comm
job:
erver_name;
ed server
e 60. DO N
ter.
n the parentment within
h of the jobmand.
48
OT
theses is n the b steps
sql02221
E
F
Enter Adva
_____ Click
_____ On thOn s
On f
Outp
Appeexist
Incluin hi
(all o
_____ When
Figure 61: Se
_____ When
M
anced value
the Advan
he Advancesuccess action
ailure action
put file
end output toting file
ude step outpistory
other values)
n done ente
et the Advanc
n you are do
Microsoft SQL Create an
Copyright ©
es for Agen
ced item in
ed page, enn Go to Go to
c:\SQ
(If yospeci
o Chec
put Chec
) (leav
ering the val
ced values for
one entering
Server featund work with © 2012, Craig
nt Job Step
n the Select
ter the follo
o the next st
o the next st
QLScripts\Lo
ou create a dfy the direc
ked
ked
e set to the
lues, the Ad
r Step 1 of th
g values on
ures that can a Linked Serg Pelkie, ALL
p 1
t a page list
owing values
tep
tep
oad_ADVWORK
different dirtory that yo
ir default va
dvanced pa
he Agent job.
the Advan
be used withrver for your RIGHTS RES
t.
s for the firs
KS_QCUST.log
rectory for you created.)
alues)
age should lo
ced page, c
h the IBM i IBM i
SERVED
st step of th
g
your SQL Sc)
ook like Fig
click the OK
he job:
cripts,
ure 61.
K button.
49
sql02222
F
_____ You a
_____ On th
Figure 62: Wh
M
are returned
he Job step
hen you retur
Microsoft SQL Create an
Copyright ©
d to the Job
list page, cl
rn to the Job
Server featund work with © 2012, Craig
step list pa
lick the New
step list, clic
ures that can a Linked Serg Pelkie, ALL
age, as show
w button to
ck the New bu
be used withrver for your RIGHTS RES
wn in Figure
add the nex
utton to add
h the IBM i IBM i
SERVED
e 62.
xt step of th
the next step
he job.
p.
50
sql02223
E
F
Enter Gene
_____ On thStep
Type
Com
(all o
_____ WhenCLIC
Figure 63: Se
M
eral values
he General p name
e
mmand
other values)
n done enteCK THE OK
et the Genera
Microsoft SQL Create an
Copyright ©
for Agent
page, ente
Creat
Trans
EXEC ) at
wherethat y
) (leav
ering the val BUTTON.
al values for S
Server featund work with © 2012, Craig
Job Step 2
r the followi
te ADVWORKS/
sact-SQL sc
('CREATE TAcusnum nulstnam chinit chstreet chcity chstate chzipcod nu
linked_serv
e linked_seyou defined
e set to the
lues, the Ge
Step 2 of the
ures that can a Linked Serg Pelkie, ALL
2
ing values f
/QCUST
ript (T-SQL)
ABLE ADVWORumeric (6, 0har (8) har (3) har (13) har (6) har (2) umeric (5, 0ver_name;
erver_name is earlier.
ir default va
eneral page
Agent job.
be used withrver for your RIGHTS RES
for the seco
)
RKS.QCUST ( 0) NOT NULL NOT NULL NOT NULL NOT NULL NOT NULL NOT NULL0) NOT NULL
s the name
alues)
e should loo
h the IBM i IBM i
SERVED
nd step of t
L, L, L, L, L, L, L)'
of the linke
ok like Figure
the job:
ed server
e 63. DO N
51
OT
sql02231
E
F
Enter Adva
_____ Click
_____ On thOn s
On f
Outp
Appeexist
Incluin hi
(all o
_____ When
Figure 64: Se
_____ When
_____ You asecon
_____ On th
M
anced value
the Advan
he Advancesuccess action
ailure action
put file
end output toting file
ude step outpistory
other values)
n done ente
et the Advanc
n you are do
are returnednd step of th
he Job step
Microsoft SQL Create an
Copyright ©
es for Agen
ced item in
ed page, enn Go to Quit t
c:\SQ
(If yospeci
o Chec
put Chec
) (leav
ering the val
ced values for
one entering
d to the Job he job listed
list page, cl
Server featund work with © 2012, Craig
nt Job Step
n the Select
ter the follo
o the next st
the job repo
QLScripts\Lo
ou create a dfy the direc
ked
ked
e set to the
lues, the Ad
r Step 2 of th
g values on
step list pad on the pag
lick the New
ures that can a Linked Serg Pelkie, ALL
p 2
t a page list
owing values
tep
orting failure
oad_ADVWORK
different dirtory that yo
ir default va
dvanced pa
he Agent job.
the Advan
age, as showge.
w button to
be used withrver for your RIGHTS RES
t.
s for the sec
e
KS_QCUST.log
rectory for you created.)
alues)
age should lo
ced page, c
wn in Figure
add the nex
h the IBM i IBM i
SERVED
cond step o
g
your SQL Sc)
ook like Fig
click the OK
e 62. You sh
xt step of th
f the job:
cripts,
ure 64.
K button.
hould see th
he job.
52
sql02232
e
E
F
Enter Gene
_____ On thStep na
Type
Comma
(all othe
_____ WhenCLIC
Figure 65: Se
M
eral values
he General me
nd
er values)
n done enteCK THE OK
et the Genera
Microsoft SQL Create an
Copyright ©
for Agent
page, ente
INSERT I
Transact
INSERT I (cusn SELE FROM
where ldefined by the li
(leave s
ering the val BUTTON.
al values for S
Server featund work with © 2012, Craig
Job Step 3
r the followi
INTO ADVWOR
t-SQL script
INTO linkednum, lstnamECT cusnum,M SQL400.db
linked_serve
earlier and inked serve
et to their d
lues, the Ge
Step 3 of the
ures that can a Linked Serg Pelkie, ALL
3
ing values f
RKS/QCUST
t (T-SQL)
d_server_namm, init, str lstnam, ino.QCUST;
er_name is thcatalog_namr.
default value
eneral page
Agent job.
be used withrver for your RIGHTS RES
for the third
me.catalog_reet, city,nit, street
he name of me is the na
es)
e should loo
h the IBM i IBM i
SERVED
(and final)
_name.ADVWOR state, zip, city, sta
the linked same of the
ok like Figure
step of the
RKS.QCUST pcod) ate, zipcod
server that ycatalog use
e 65. DO N
53
job:
you d
OT
sql02241
E
F
Enter Adva
_____ Click
_____ On thOn s
On f
Outp
Appeexist
Incluin hi
(all o
_____ When
Figure 66: Se
_____ When
M
anced value
the Advan
he Advancesuccess action
ailure action
put file
end output toting file
ude step outpistory
other values)
n done ente
et the Advanc
n you are do
Microsoft SQL Create an
Copyright ©
es for Agen
ced item in
ed page, enn Quit t Quit t
c:\SQ
(If yospeci
o Chec
put Chec
) (leav
ering the val
ced values for
one entering
Server featund work with © 2012, Craig
nt Job Step
n the Select
ter the follo
the job repo
the job repo
QLScripts\Lo
ou create a dfy the direc
ked
ked
e set to the
lues, the Ad
r Step 3 of th
g values on
ures that can a Linked Serg Pelkie, ALL
p 3
t a page list
owing values
orting succe
orting failure
oad_ADVWORK
different dirtory that yo
ir default va
dvanced pa
he Agent job
the Advan
be used withrver for your RIGHTS RES
t.
s for the thi
ess
e
KS_QCUST.log
rectory for you created.)
alues)
age should lo
ced page, c
h the IBM i IBM i
SERVED
ird step of t
g
your SQL Sc)
ook like Fig
click the OK
he job:
cripts,
ure 66.
K button.
54
sql02242
F
_____ You ajob s
Figure 67: Ve
M
are returnedteps as sho
erify that the
Microsoft SQL Create an
Copyright ©
d to the Job wn in the fig
Job step list
Server featund work with © 2012, Craig
step list pagure.
looks like thi
ures that can a Linked Serg Pelkie, ALL
age, as show
is before cont
be used withrver for your RIGHTS RES
wn in Figure
tinuing.
h the IBM i IBM i
SERVED
e 67. You sh
hould see th
55
e three
sql02251
S
F
Set job sch
_____ In th
_____ On thin Fig
Figure 68: Se
_____ For t
_____ Whendialo
M
hedule prop
e Select a
he Schedulegure 68 is d
et the Job Sch
his test, setName
Schedu
Enabled
Frequen
Frequen
Daily fr
Starting
Ending
Duratio
Duratio
n done enteg shown in
Microsoft SQL Create an
Copyright ©
perties
page sectio
e list page, cisplayed.
hedule Proper
t the Job Sc
le type
d
ncy / Occurs
ncy / Recurs
equency / Oc
g at
at
on / Start date
on / No end d
ering the valFigure 69.
Server featund work with © 2012, Craig
on, click the
click the Ne
rties for the j
hedule Prop
every
ccurs every
e
ate
lues, click th
ures that can a Linked Serg Pelkie, ALL
e Schedules
w button. T
job.
perties value
Load_
Recu
Chec
Daily
1 day
2 min
12:00
11:59
(curr
Selec
he OK butto
be used withrver for your RIGHTS RES
s item.
The Job Sch
es to the fol
_ADVWORK
rring
ked
y
y(s)
nutes
0:00 AM
9:59 PM
rent date)
cted
on. You are
h the IBM i IBM i
SERVED
edule Prope
llowing:
KS_QCUST
returned to
erties dialog
o the Job Pro
56
g shown
sql02261
operties
F
_____ Verify
Figure 69: Ve
M
y that the S
erify that the
Microsoft SQL Create an
Copyright ©
Schedules en
Schedule list
Server featund work with © 2012, Craig
ntry is prese
t looks like th
ures that can a Linked Serg Pelkie, ALL
ent, as show
his before con
be used withrver for your RIGHTS RES
wn in Figure
ntinuing.
h the IBM i IBM i
SERVED
e 69.
57
sql02262
S
F
Set the Not
_____ Click Figur
_____ Checjob c
Figure 70: Se
_____ At th
• C
• A
• Sso
• C
_____ NOWServe
M
tifications
the Notificre 70 is disp
k the Writecompletes
et the Notifica
is point, you
Completed th
• Delete
• Creat
• Use thSQL S
Assigned fail
et up a recuo that you c
Created a no
W, click the Oer Agent job
Microsoft SQL Create an
Copyright ©
options
cations itemplayed.
e to the Wioption.
ations to look
u have done
he definition
e the existin
e the table
he INSERT IServer table
ure/success
urring job sccan quickly s
otification to
OK button tbs list.
Server featund work with © 2012, Craig
m in the Sel
ndows App
k like this.
e the followi
n of a job th
ng database
on the IBM
NTO SQL sta
s continuatio
chedule to rsee results)
o write an en
to close the
ures that can a Linked Serg Pelkie, ALL
lect a page
plication Ev
ing:
hat includes
e file on you
i
atement to l
on options a
run this job .
ntry to the W
Job Propert
be used withrver for your RIGHTS RES
e section. Th
vent log ite
three T-SQ
ur IBM i (the
oad the IBM
and logging
every 2 min
Windows Ev
ties dialog.
h the IBM i IBM i
SERVED
he Notificati
em, and sel
QL steps:
e linked serv
M i table wit
options for
nutes (this i
vent Log.
The job is a
ons panel s
ect the Wh
ver)
th data from
each job st
is just for te
added to the
58
shown in
en the
sql02271
m the
tep.
esting,
e SQL
F
DAaca
F
_____ Look that y
Figure 71: Yo
Disable thAt this pointall of the resclear the Wiand observe
_____ In thin Fig
Figure 72: Rig
M
at the SQLyou created
ou should now
he job, pt, you are results of the jndows Even
e its run hist
e SQL Servegure 72. (In
ght-click the j
Microsoft SQL Create an
Copyright ©
L Server Agd in the list o
w see the job
repare foeady to test job, you wil
nt log and dtory.
er Agent Job IBM i term
job and selec
Server featund work with © 2012, Craig
gent, Jobs iof jobs, as s
listed in the
or testing the job (it ll temporarielete the file
bs list, rights, this is sim
ct the Disable
ures that can a Linked Serg Pelkie, ALL
item in the shown in Fig
Object Explo
g the job might have ly disable it e on your IB
t-click your milar to "put
e option to pr
be used withrver for your RIGHTS RES
Object Explgure 71.
orer.
already run to prevent BM i. After t
job and clictting the job
revent it from
h the IBM i IBM i
SERVED
orer. You sh
n). To be su it from runthat, you wi
ck the Disabb on hold".)
m running.
hould see th
ure that you ning. You wll enable th
ble item, as)
59
he job
sql02281
will see will then e job
s shown
sql02282
F
F
_____ You w
Figure 73: Th
_____ Go toViewe
_____ In thas shconfi
Notethan
Figure 74: In
M
will see the
he Disable Job
o the Windoer).
e Event Viehown in Figugured so th
e: the list of those show
the Event Vi
Microsoft SQL Create an
Copyright ©
Disable Job
bs dialog con
ws Event Vi
wer, right-cure 74. (Notat you can't
f items that wn in the figu
iewer, right-c
Server featund work with © 2012, Craig
s dialog as
firms that the
iewer progra
click the Appte: in some t clear even
you see undures in this
click Applicati
ures that can a Linked Serg Pelkie, ALL
shown in Fi
e job is disab
am (Contro
plication it corporate ets. If you ca
der the Eve section.
ion and selec
be used withrver for your RIGHTS RES
gure 73. Cli
bled.
l Panel, Adm
tem and clicenvironmenan't clear ev
nt Viewer (L
ct the Clear al
h the IBM i IBM i
SERVED
ick the Clos
ministrative
ck the Clearts, your PC vents, simpl
Local) item
ll Events item
se button.
Tools, Even
r all Events might be ly continue
may be diff
m.
60
sql02283
nt
s item,
on.)
ferent
sql02284
F
F
_____ When
Figure 75: Cli
_____ If youlike Fmess
Figure 76: Th
_____ You cminu
_____ On yo
DLTF
It is O
M
n prompted
ick the No op
u were ableFigure 76. Tsages that a
he Application
can leave thtes.
our IBM i, e
ADVWORKS/Q
OK if the file
Microsoft SQL Create an
Copyright ©
to save the
ption when pr
to clear yoThe reason fare generate
n event list sh
he Event Vie
enter the fol
CUST
e is not foun
Server featund work with © 2012, Craig
e Application
rompted to sa
ur Applicatioor clearing ted by the SQ
hould be emp
ewer dialog
lowing com
nd.
ures that can a Linked Serg Pelkie, ALL
n events (Fig
ave the Appli
on events, ythe events iQL Server A
pty.
open. You w
mand on a
be used withrver for your RIGHTS RES
gure 75), cl
ication event
your Event Vis so that yo
Agent job.
will be revie
5250 comm
h the IBM i IBM i
SERVED
lick the No
log.
Viewer dialoou can easil
wing Agent
mand line:
button (if p
og should noy see the ev
events in a
61
ossible).
sql02285
ow look vent
sql02286
a few
F
F
_____ In thin Fig
Figure 77: Rig
_____ The E
_____ Withi
Figure 78: Th
M
e SQL Servegure 77.
ght-click the
Enable Jobs
in the next
he Enable Job
Microsoft SQL Create an
Copyright ©
er Agent Job
Agent job an
message sh
2 minutes, t
bs dialog now
Server featund work with © 2012, Craig
bs list, right
nd select the
hown in Fig
the job will
w shows that t
ures that can a Linked Serg Pelkie, ALL
t-click your
Enable option
ure 78 is dis
start runnin
the job is ena
be used withrver for your RIGHTS RES
job and clic
n.
splayed. Cli
ng.
abled.
h the IBM i IBM i
SERVED
ck the Enab
ck the Clos
ble item, as
se button.
62
shown
sql02291
sql02292
R
F
Review th_____ Wait
_____ In thshow
Figure 79: Rig
M
he Agent at least 2 m
e SQL Servewn in Figure
ght-click the
Microsoft SQL Create an
Copyright ©
t job's ruminutes.
er Agent Job 79.
Agent job an
Server featund work with © 2012, Craig
n history
bs list, right
nd select the
ures that can a Linked Serg Pelkie, ALL
y
t-click your
View History
be used withrver for your RIGHTS RES
job and sele
item.
h the IBM i IBM i
SERVED
ect the View
w History i
63
item, as
sql02301
F
F
_____ The Lentrie
_____ ExpaFigur
Figure 80: Th
_____ If a spane
The "your with prope
Figure 81: Yo
M
Log File Viewes for your j
nd the entrre 80.
his history sho
step is showl of the view
"error" that IBM i whenthe next steerties on pa
ou can click an
Microsoft SQL Create an
Copyright ©
wer programjob.
ies so that y
ows that the
wn as endingwer to displa
is shown he it does notep" when yoage 49).
n individual s
Server featund work with © 2012, Craig
m opens, as
you can see
Agent job ha
g in error, clay the conte
ere is the att exist. This ou set the A
step within th
ures that can a Linked Serg Pelkie, ALL
shown in F
e the status
as been run t
lick the stepent of the er
ttempt to dr is why you
Advanced pro
he job and vie
be used withrver for your RIGHTS RES
Figure 80. Yo
of each ind
two times.
p to select itrror messag
rop (delete) set the "onoperties for
ew the compl
h the IBM i IBM i
SERVED
ou may see
ividual step
t. You can age.
the ADVWORK failure acti
r Step 1 of t
lete results fo
one or mor
, as shown
adjust the bo
KS/QCUST fileon" to "contthe job (see
for that step.
64
re
in
sql02302
ottom
e on tinue the
sql02303
F
F
_____ Go tothe Amess
Figure 82: Th
_____ Doubmess
Figure 83: Do
M
o the Event Application esage for eac
he Event View
ble-click on tsage as show
ouble-click an
Microsoft SQL Create an
Copyright ©
Viewer progevents, clickch run of the
wer shows the
the top-moswn in Figure
n event viewe
Server featund work with © 2012, Craig
gram. If youk the Actione Agent job,
e completion
st Applicatioe 82, which
er message to
ures that can a Linked Serg Pelkie, ALL
u did not clon, Refresh , as shown i
message for
on message gives you in
o see the Eve
be used withrver for your RIGHTS RES
ose the Evenmenu item.in Figure 82
r the Agent jo
. You will senformation
ent Properties
h the IBM i IBM i
SERVED
nt Viewer di. You will se2.
ob.
ee the Eventabout the A
s.
ialog after cee an event
t PropertiesAgent job.
65
clearing log
sql02311
s
sql02312
F
I
F
_____ Finalthe losame
Figure 84: Th
If the Age_____ If the
indica
_____ You cObjecmenu
Figure 85: Rig
M
ly, go to theog file that we informatio
he log file sho
ent Job ee Agent Job ate which st
can edit thect Explorer, u, as shown
ght-click the j
Microsoft SQL Create an
Copyright ©
e c:\SQLScriwas configun that you s
ows the job a
ends in er does not rutep in the jo
steps in the right-click t in Figure 8
job and selec
Server featund work with © 2012, Craig
ipts directoured for eachsee in the L
nd the steps.
rror un successfuob did not co
e Agent Jobthe Agent jo
85.
ct the Proper
ures that can a Linked Serg Pelkie, ALL
ory and openh of the jobog File View
.
ully, look caomplete suc
b by returninob and selec
rties item
be used withrver for your RIGHTS RES
n the Load_A's steps). Th
wer program
refully at thccessfully.
ng to the Joct the Prope
h the IBM i IBM i
SERVED
ADVWORKS_QC
his file showm (see Figure
he messages
b Propertieserties item f
UST.log file ws much of te 80and Fig
s. The mess
s dialog. In from the po
66
(this is the
gure 81).
sql02321
sages
the p-up
sql02331
F
D
SYs
Kyd
_____ To edthen
Figure 86: On
_____ When
Disable th_____ Now
won't
SummarYou've now server. In fu
Keep in minyou require.different libr
M
dit a job ste click the Ed
n the Steps p
n done, try
he job that you hat keep runn
ry worked thro
uture labs, y
d that you c For examp
rary lists.
Microsoft SQL Create an
Copyright ©
p, click the dit button. Y
age, click the
running the
ave run the jing. Follow
ough many you will mak
can create aple, you mig
Server featund work with © 2012, Craig
Steps itemYou can ma
e job step to
e job again.
job and revthe steps sh
of the optioke additiona
as many diffht want to c
ures that can a Linked Serg Pelkie, ALL
m in the Seleke any requ
select it, the
iewed its rehown in Figu
ons that are al use of the
ferent linkedcreate differ
be used withrver for your RIGHTS RES
ect a page auired change
en click the Ed
esults, you sure 72 and
available toe linked serv
d server defrent linked s
h the IBM i IBM i
SERVED
area, then cles to the job
dit button.
should disabFigure 73 to
o you when ver definition
finitions to tserver defin
lick the job b step.
ble the job so disable th
you use a ln.
the same IBnitions to use
67
step,
sql02332
so that it e job.
inked
BM i as e
Top Related