![]() ![]() SELECT is based on similar code I wrote to turn an arbitrary table into an HTML string.Csvkit: query csv files using SQL from the command lineĬsv is the most common file format that you will use when you deal with data all major spreadsheets like Excel or Libre Office Calc support saving / exporting sheets as csv also, csv is used by default in most databases like MySQL and SQL server when perform exports, would be nice if you could perform SQL commands on a csv file without the need to re-import the csv to a Database or use a script language like Python? You can do all this using csvkit!. = 'SELECT * FROM Customers', = OUTPUT, = 'ORDER BY CustomerId' ![]() SET = + sys.sp_executesql nvarchar(MAX) OUTPUT', OUTPUT ![]() SET = (SELECT '' + + '' FROM #dynSql ' + + ' FOR XML PATH(''''m_m'''')) ĮXEC sys.sp_executesql nvarchar(MAX) OUTPUT'', OUTPUT WHERE object_id = object_id(''tempdb.#dynSql'') SELECT * INTO #dynSql FROM (' + + ') sub It should contain the words 'ORDER nvarchar(MAX) = NULL OUTPUT -The CSV output of the procedure. It should not include an ORDER BY nvarchar(MAX) = NULL, -An optional ORDER BY clause. Any ORDER BY clause needs to be passed in the separate ORDER BY parameter.ĬREATE PROC nvarchar(MAX), -A query to turn into CSV format. Description: Turns a query into a formatted CSV. This is useful if you don't want to write custom code every time you want to turn a SQL table into a CSV string. I've created a proc that will dynamically create a CSV out of any arbitrary table, without needing to explicitly specify the columns. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |