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.
Author |
Topic |
ron_lhr
Starting Member
1 Post |
Posted - 2010-06-28 : 12:17:15
|
Hi,I've got a query that on my machine I run inside SSMS and it works nicely but if I fire up the command line and use osql and paste the query in or use sqlcmd and call it from a .sql file, it gives me this error:Msg 245, Level 16, State 1, Server MSSQLCLUSTER\MSSQLCLUSTER, Line 1Conversion failed when converting the varchar value 'Column 0' to data type int.I've been googling like crazy on this and all I've managed to find from Microsoft's site is a big yellow box telling me that behaviors may be different between osql and SSMS ... but with no other guidance or information.What do I need to do to get this to work in a manner that I can batch it? I don't want to run it manually by opening up SSMS every day.The query:SELECT CAST("Column 0" as integer) as fsa_firm_ref,CAST("Column 1" as varchar(400)) as firm_name,CAST("Column 2" as int) as firm_legal_status_type_code,CAST("Column 3" as int) as firm_type_code,CAST("Column 4" as char(1)) AS auth_to_hold_client_money ,CAST("Column 5" as varchar(255)) AS address_1 ,CAST("Column 6" as varchar(255)) AS address_2 ,CAST("Column 7" as varchar(255)) AS address_3,CAST("Column 8" as varchar(255)) AS address_4 ,CAST("Column 9" as varchar(255)) AS address_5 ,CAST("Column 10" as varchar(255)) AS address_6 ,CAST("Column 28" as varchar(15)) AS postcode ,CAST("Column 29" as varchar(200)) AS telephone ,CAST("Column 30" as varchar(200)) AS fax ,CAST("Column 19" as varchar(30)) AS current_authorisation_status,CAST("Column 20" as datetime) AS status_last_changed_date,CAST("Column 21" as datetime) AS first_authorised_date ,CAST("Column 22" as varchar(400)) AS sortkey ,CAST("Column 23" as datetime) AS last_update_date,getdate() as load_date into firm_authorisationfrom AUTGO |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|
|