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 2000 Forums
 SQL Server Development (2000)
 Writing .sql or .txt file in sql server stored procedure

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-07-06 : 11:56:45
Nitin writes " Hello,


1) Is there any way to write Operating System file in
server?

My problem is as follows

I have to retrive some data related to one no. and
write it into on .sql or .txt file in such a format that
same can be porting into other database having same database
structure.

2) Is it possible to define a record type in SQL Server?

e.g. I have defined following in Oracle

/* Defien the record structure as follows */

TYPE tbllist_rec IS RECORD(
tblname USER_TAB_COLUMNS.TABLE_NAME%TYPE,
colname USER_TAB_COLUMNS.COLUMN_NAME%TYPE);

/* Create an instance of that record type */

TYPE tab_tbllist IS TABLE OF tbllist_rec;

/* Define a veriable of record type */

tbllist tab_tbllist;

/* In following line I have retrived multiple records
in select statement and inserted that all records in
in table type variable tbllist. i.e insteade of retriving
one by one record I inserted all records at a time */

SELECT TABLE_NAME, COLUMN_NAME BULK COLLECT INTO tbllist
FROM USER_CONS_COLUMNS NATURAL JOIN V_ACCOUNTINFO ORDER BY 1;


Is there any way in SQL erver to do this as above?

Thanks & Regards

Nitin"

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-07-06 : 17:20:33
DECLARE a table variable. Insert the results of your insert statement using INSERT @table(columnlist) SELECT columns FROM whatever. You need to buy a book on Transact-SQL if you don't know how to do something this simple. The Sam's book "Teach Yourself Transact-SQL in 21 Days" is a great book.

For the importing from a text file or output of a text file, you can use DTS. Again, buy the book.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page
   

- Advertisement -