Home Forums SQL Server 2005 Development execute SQL server query from Dos command prompt/ batch file. RE: execute SQL server query from Dos command prompt/ batch file.

  • to run the SQL use SQL Command, but use the following to format the data the way you requested

    DROP TABLE [#testtable]

    GO

    SELECT [name],

    [object_id] AS c1,

    principal_id AS c2,

    [schema_id] AS c3

    INTO #testtable

    FROM sys.tables

    SELECT NAME,Column_name,ItemValue FROM (SELECT *

    FROM [#testtable]) AS a

    UNPIVOT (ItemValue FOR Column_name IN (c1,c2,c3)) AS unpvt

    ORDER BY 1,2