Advertisement
Guest User

Querying results of a stored procedure

a guest
Feb 19th, 2012
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. exec database..proc 'arg1','arg2','arg3'
  2.  
  3. select distinct column1 from
  4. (exec database..proc 'arg1','arg2','arg3')
  5.  
  6. select
  7. <any columns you like>
  8. from
  9. dbo.myFunc( 'foo', 'bar', 1 )
  10. where
  11. <whatever clauses you like>
  12. order by
  13. <same>
  14.  
  15. CREATE TABLE dbo.Test_Proc_Results_To_Table
  16. (
  17. my_id INT NOT NULL,
  18. my_string VARCHAR(20) NOT NULL
  19. )
  20. GO
  21.  
  22. CREATE PROCEDURE dbo.Test_Proc_Results_To_Table_Proc
  23. AS
  24. BEGIN
  25. SELECT
  26. 1 AS my_id,
  27. 'one' AS my_string
  28. END
  29. GO
  30.  
  31. INSERT INTO dbo.Test_Proc_Results_To_Table (my_id, my_string)
  32. EXEC dbo.Test_Proc_Results_To_Table_Proc
  33. GO
  34.  
  35. SELECT * FROM dbo.Test_Proc_Results_To_Table
  36. GO
  37.  
  38. SELECT DISTINCT Column1
  39. FROM procName(parameter1, parameter2, parameter3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement