Thursday, July 31, 2014

Problem of Uncertain no. of columns

Ok. you've two options in that case


1. use a temporary table with same structure as SP output and populate it as below



INSERT #Temp
EXEC Proc...

Now use temp table to fill your table



INSERT YourTable (col1,col2,col3,..)
SELECT Col1,NULL,Col2,...
FROM #Temp

fill missing columns with NULL values


2. use a direct select based on distributed query



INSERT YourTable (Col1,Col2,Col3,..)
Select Col1,NULL,Col2,..
from
OPENROWSET('SQLOLEDB','Data Source=Servername;Trusted_Connection=yes;
Integrated Security=SSPI','Execute yourdbname..Proc')





Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c



No comments:

Post a Comment