Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
jayanth_jyothi
Starting Member
11 Posts |
Posted - 2007-08-16 : 19:16:43
|
| HiI need to solve one problemthere is one table say TableA with columns orgid intsuppose say some 1000 records are therefor each record based on the value of orgid i have to generate a script like thisif not exists (select * from TableB where orgid=each record value) then insert into tableb (orgid) else print already existslike this i have to generate a scriptcan u please give me idea how to do this in dynamic sql |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-16 : 19:27:04
|
Why the use of DYNAMIC SQL?INSERT TableB ( OrgID )SELECT a.OrgIDFROM TableA AS aLEFT JOIN TableB AS b ON b.OrgID = a.OrgIDWHERE b.OrgID IS NULL E 12°55'05.25"N 56°04'39.16" |
 |
|
|
jayanth_jyothi
Starting Member
11 Posts |
Posted - 2007-08-16 : 19:40:11
|
| see i have to generate sql script for thisnot sql querysee tableA there is 10,11,12 idsbased on these values i have to generate three sql statments as scripts |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-08-17 : 02:20:54
|
| http://vyaskn.tripod.com/code/generate_inserts.txtMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|