You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.8 KiB

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[ProcToTable] Script Date: 9/27/2019 1:30:14 PM ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. CREATE procEDURE [dbo].[ProcToTable]
  9. (
  10. @SPAndParameters nvarchar(max)
  11. ,@tempTable VARCHAR(20)
  12. )
  13. AS
  14. BEGIN
  15. DECLARE @Driver nvarchar(20)
  16. DECLARE @ConnectionString nvarchar(200)
  17. DECLARE @SQL nvarchar(max)
  18. DECLARE @SQL2 nvarchar(max)
  19. DECLARE @RowsetSQL nvarchar(max)
  20. SET @Driver = '''' + 'MSDASQL' + ''''
  21. SET @ConnectionString = '''' +'DRIVER={SQL Server};SERVER=192.168.2.1;UID=domestic_user;PWD=ime1234' + ''''
  22. SET @RowsetSQL = '''' +'SET FMTONLY OFF ' + '' + @SPAndParameters + '' + ''''
  23. SET @SQL = ' SELECT * INTO ' + @tempTable + ' FROM OPENROWSET('
  24. SET @SQL = @SQL + @Driver + ',' + @ConnectionString + ',' + @RowsetSQL + ')'
  25. EXEC (@SQL)
  26. PRINT(@SQL)
  27. END
  28. GO