Insert

Insert

Post by Neil Pik » Fri, 30 Oct 1998 04:00:00



Sean,

CREATE TABLE #tb_setopts
(SetOptName varchar(35) NOT NULL ,SetOptValue varchar(35) null)
INSERT INTO #tb_setopts (SetOptName,SetOptValue)
EXEC('dbcc useroptions')

Quote:> How can I insert the results of a DBCC into a table.

 Neil Pike MVP/MCSE
 Protech Computing Ltd
 (Please post ALL replies to the newsgroup only unless indicated otherwise)
 
 
 

Insert

Post by Sean Arm » Mon, 02 Nov 1998 04:00:00


Could you please tell me why this doesn't work.
The table is created and the dbcc executes but no record is inserted.

Thank you very much.

CREATE TABLE #maint
(Results varchar(255) NOT NULL)
INSERT INTO #maint(results)
EXEC('dbcc checkdb(master)')


>Sean,

>CREATE TABLE #tb_setopts
>(SetOptName varchar(35) NOT NULL ,SetOptValue varchar(35) null)
>INSERT INTO #tb_setopts (SetOptName,SetOptValue)
>EXEC('dbcc useroptions')

>> How can I insert the results of a DBCC into a table.

> Neil Pike MVP/MCSE
> Protech Computing Ltd
> (Please post ALL replies to the newsgroup only unless indicated otherwise)


 
 
 

Insert

Post by Neil Pik » Tue, 03 Nov 1998 04:00:00


Sean,

Q.  How can I insert the output of a dbcc command into a SQL Server table?
(v1.0 02.11.1998)

A.  Some DBCC commands support this directly via the "insert into exec" type
format, others don't.  Examples of both are given.

A dbcc command that works "normally" is useroptions - this is an example from
the books-online :-

drop table #tb_setopts
go
CREATE TABLE #tb_setopts (SetOptName varchar(35) NOT NULL ,SetOptValue
varchar(35) null)
INSERT INTO #tb_setopts (SetOptName,SetOptValue)
EXEC('dbcc useroptions')
select * from #tb_setopts

One that doesn't is dbcc checkdb.  To make this work you'll need to use
xp_cmdshell and ISQL as follows :-

DROP TABLE #maint
go


CREATE TABLE #maint (Results varchar(255) NOT NULL)
INSERT INTO #maint(Results) EXEC('master..xp_cmdshell ''ISQL -E -Q"dbcc
checkdb(master)"''')
select * from #maint

 Neil Pike MVP/MCSE
 Protech Computing Ltd
 (Please post ALL replies to the newsgroup only unless indicated otherwise)

 
 
 

1. Multi insert (bulk insert)

Is it possible in MS-SQL 7.0 to insert multiple rows in one go (without
saving to disk and using bulk insert) ?

What I want is something like this:

INSERT INTO MyTable (id, value)
VALUES (1,'value1'),(2,'value2'),(3,'value3')........

insted of doing

INSERT INTO MyTable (id, value)
VALUES (1,'value1')

INSERT INTO MyTable (id, value)
VALUES (2,'value2')

INSERT INTO MyTable (id, value)
VALUES (3,'value3')

and so on....

I insert typically 5-10 values at a time. The program is a multiuser web
application so storing to disk is not something I want to do.
--
P?l Andreassen

2. Do I need to destroy a CDatabase Obj. after use.

3. Multiple Insert Only Inserts One Row

4. DBA jobs in Atlanta

5. Inserting a insert statement into a stored procdure

6. tempdb in memory

7. Insert trigger: inserted table empty!!!!!

8. Retriving Database's Keywords

9. Multiple Row Insert with Instead of Insert Trigger

10. Bulk Insert only inserting every 2nd row

11. Error when bulk insert follows another large bulk insert

12. Combining Insert Values and Insert Select Statements into one Clause

13. Check changed fields in inserted and Insert instead of edit