Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 select into

Author  Topic 

satya068
Posting Yak Master

233 Posts

Posted - 2010-03-17 : 10:28:59
Hi..

i was trying to insert data into a new table and i wondering any one could help me how to turn 'ON'select into option in SP_dboption in the model database.
when i chek the stored procedure it was already set to ON but when i run sql script it was throwing me an error message.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-17 : 10:35:27
whats the error message?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

satya068
Posting Yak Master

233 Posts

Posted - 2010-03-17 : 10:43:02
hi..
herego my script

select * into NEW_TABLE1 from
(SELECT tab.name AS table_name,

ind.rows as row_count

FROM sys.tables tab INNER JOIN

sys.sysindexes ind ON tab.object_id = ind.id AND ind.indid < 2)

now i want to insert that 2 columns into NEW_TABLE1 in the same database.

is there anyother way to insert these record into NEW_TABLE1?


thanx

satya
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-03-17 : 11:03:40
SELECT
tab.name AS table_name,
ind.rows as row_count

INTO NEW_TABLE1

FROM sys.tables tab
INNER JOIN sys.sysindexes ind
ON tab.object_id = ind.id AND ind.indid < 2


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-03-17 : 11:04:44
But you have not answered Visakh's question!
Posting the error message is always important.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

satya068
Posting Yak Master

233 Posts

Posted - 2010-03-17 : 11:08:03
hi..

i am unable to access my database due to connection problem ..that the reason i am unable to paste my error to visakh's..reply.

i ill try ur script once i got connection to database.

thanx again


samitee
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-03-17 : 11:18:42
Ah - ok.
But think about it: SELECT INTO needs the destination table isn't already present.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

satya068
Posting Yak Master

233 Posts

Posted - 2010-03-17 : 11:38:55

thanx
i got expected result.

quote:
Originally posted by webfred

SELECT
tab.name AS table_name,
ind.rows as row_count

INTO NEW_TABLE1

FROM sys.tables tab
INNER JOIN sys.sysindexes ind
ON tab.object_id = ind.id AND ind.indid < 2


No, you're never too old to Yak'n'Roll if you're too young to die.



Satya
Go to Top of Page

satya068
Posting Yak Master

233 Posts

Posted - 2010-03-17 : 11:41:09
DESTINATION TABLE
whic i already created manually with datatype varchar(100) n row_count as int
quote:
Originally posted by webfred

Ah - ok.
But think about it: SELECT INTO needs the destination table isn't already present.


No, you're never too old to Yak'n'Roll if you're too young to die.



Satya
Go to Top of Page
   

- Advertisement -