Hi,
I am running series of dynamic sql from stored procedure to update/insert rows in target database from source database. I got almost all statements to work but few I am not able to make it work. Problem is these statements are in middle of stored procedure. I cant take them out either...Here are those statments..If I run its result in query analizer it works fine.
Select @sSQL = N'alter table ' + @ps_DBName + '..member add hrank numeric(18) null, hunit numeric(18) null'
EXEC sp_executesql @sSQL
Select @sSQL = N'update ' + @ps_DBName + '..member set hrank =mr.hmy from ' + @ps_DBName + '..member m, dbsource..ranking r, ' + @ps_DBTargetName + '..temp_rank mr where m.MRank = r.rank_id and r.srankcd = mr.code and mr.MilServiceID = r.servbranchcode'
EXEC sp_executesql @sSQL
Above statement would translate dynamically to...
update dbsource..member set hrank =mr.hmy from dbsource..member m, dbsource..ranking r, dbTarget..temp_rank mr where m.MRank = r.rank_id and r.srankcd = mr.code and mr.MilServiceID = r.servbranchcode
Any work around to this? pleas help..can i use embeded vb script as work around?
I am running series of dynamic sql from stored procedure to update/insert rows in target database from source database. I got almost all statements to work but few I am not able to make it work. Problem is these statements are in middle of stored procedure. I cant take them out either...Here are those statments..If I run its result in query analizer it works fine.
Select @sSQL = N'alter table ' + @ps_DBName + '..member add hrank numeric(18) null, hunit numeric(18) null'
EXEC sp_executesql @sSQL
Select @sSQL = N'update ' + @ps_DBName + '..member set hrank =mr.hmy from ' + @ps_DBName + '..member m, dbsource..ranking r, ' + @ps_DBTargetName + '..temp_rank mr where m.MRank = r.rank_id and r.srankcd = mr.code and mr.MilServiceID = r.servbranchcode'
EXEC sp_executesql @sSQL
Above statement would translate dynamically to...
update dbsource..member set hrank =mr.hmy from dbsource..member m, dbsource..ranking r, dbTarget..temp_rank mr where m.MRank = r.rank_id and r.srankcd = mr.code and mr.MilServiceID = r.servbranchcode
Any work around to this? pleas help..can i use embeded vb script as work around?