﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / Working with Oracle  / equivalent of spool / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 21 May 2013 14:26:13 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: equivalent of spool</title><link>http://www.sqlservercentral.com/Forums/Topic1232659-1042-1.aspx</link><description>You could output to a file and run that.  Any reason to do so instead of just executing it as dynamic SQL?If you really insist on the output a file step, you could do the whole thing in a PowerShell script, or something like that.  Or write that query as a View and use BCP to output it then use PowerShell to run it.Easier would be to create a cursor for that Select statement, then step through it and execute each line as a command.Or if you can be sure it'll all fit in one command, use the For XML Path('') trick to turn it into a single statement and execute it all at once.  I'd use a cursor, though.  Easier and more reliable.</description><pubDate>Mon, 09 Jan 2012 10:51:52 GMT</pubDate><dc:creator>GSquared</dc:creator></item><item><title>equivalent of spool</title><link>http://www.sqlservercentral.com/Forums/Topic1232659-1042-1.aspx</link><description>Hi friends,    I need to drop and recreate check constraints in a few databases and would need to script this so it can be run over different databases at customer's end. Below is the sql I need to run to drop check constraintsSELECT       'ALTER TABLE  ' +       QuoteName(OBJECT_NAME(so.parent_obj)) +       CHAR(10) +       ' DROP CONSTRAINT ' +       QuoteName(CONSTRAINT_NAME)   FROM      INFORMATION_SCHEMA.CHECK_CONSTRAINTS cc     INNER JOIN sys.sysobjects so    ON cc.CONSTRAINT_NAME = so.[name]  In Oracle, I can spool the results of the above sql to a file and run the file to drop the constraints.. Is there a way to do the same in SQL Server?  Please give me your thoughtsThank you</description><pubDate>Mon, 09 Jan 2012 10:45:37 GMT</pubDate><dc:creator>newbieuser</dc:creator></item></channel></rss>