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 2008 Forums
 Transact-SQL (2008)
 Exporting a Flat File

Author  Topic 

RajJol
Starting Member

17 Posts

Posted - 2011-01-28 : 11:00:05
Hi,

I have a very simply query which reads:-

select [Table_Name]
,[Company_No]
,[Client_No]
,[Client_Date]
,[Client_Time]
,[Client_Dupl]
,[Insurer_No]
,[RiskReference]
,[RiskHandler]
,[CLAIM_REF]
,[Record_Count]
,[Date_Detected] from dbo.Test_Checker where cast(Date_Detected as date) = CAST(getdate() as Date)


I need to the output of this as a flat file.

Any help would be much appreciated.

Thanks in advance.

Raj.

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-01-28 : 11:06:58
Have a look at bcp or ssis.
Might be easier to copy to a table first

select [Table_Name]
,[Company_No]
,[Client_No]
,[Client_Date]
,[Client_Time]
,[Client_Dupl]
,[Insurer_No]
,[RiskReference]
,[RiskHandler]
,[CLAIM_REF]
,[Record_Count]
,[Date_Detected]
into mytable
from dbo.Test_Checker where cast(Date_Detected as date) = CAST(getdate() as Date)

You also might want to format into character strings.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -