Hi,
i have a SP that populates a datagridview.
if i have only SELECT statment is returns the rows but i need to have if else and when i do that i get the error of cannot find table 0. the Sp gets data from an xls file dumps it in a temp table then does a lookup to an existing table, the results should be returned to the DGV.
thanks for looking
SELECT @sql = 'SELECT * into ##GETDATA FROM OPENROWSET(' + '''Microsoft.Jet.OLEDB.4.0'', ' + '''Excel 8.0;DATABASE=' + @FPATH + ';HDR=yes'', ' + '''SELECT * FROM [SHEET1$]'')' EXEC(@sql) If exists (Select * from tempdb.information_schema.columns where table_name = '##getdata' and column_name = 'SIM') ALTER TABLE ##getdata ADD [NUMBER] nvarchar(30) NOT NULL DEFAULT(1) else if exists (Select * from tempdb.information_schema.columns where table_name = '##getdata' and column_name = 'NUMBER') ALTER TABLE ##getdata ADD SIM nvarchar(30) GO ---