sqlcmd

Error trying to connect to a SQL Server using sqlcmd (from Ubuntu command line)?

醉酒当歌 提交于 2020-01-15 05:02:28
问题 I am finding some problem trying to connect to a SQL Server instance from an Ubuntu machine using sqlcmd . So I installed sqlcmd as explained here: https://docs.microsoft.com/it-it/sql/linux/sql-server-linux-setup-tools?view=sql-server-ver15#ubuntu The SQL server seems to be reachable because I can successfully connect to the 1433 port of its IP via Telnet. Then I tried to connect to one of my database on this server, in this way: ./sqlcmd -S MY_SERVER_IP\ESB_WSO2_USER_DB Where MY_SERVER_IP

Display DataType and Size of Column from SQL Server Query Results at Runtime

百般思念 提交于 2020-01-12 15:37:25
问题 Is there a way to run a query and then have SQL Server management studio or sqlcmd or something simply display the datatype and size of each column as it was received. Seems like this information must be present for the transmission of the data to occur between the server and the client. It would be very helpful to me if it could be displayed. A little background: The reason I ask is because I must interface with countless legacy stored procedures with anywhere from 50 to 5000+ lines of code

Display DataType and Size of Column from SQL Server Query Results at Runtime

有些话、适合烂在心里 提交于 2020-01-12 15:37:12
问题 Is there a way to run a query and then have SQL Server management studio or sqlcmd or something simply display the datatype and size of each column as it was received. Seems like this information must be present for the transmission of the data to occur between the server and the client. It would be very helpful to me if it could be displayed. A little background: The reason I ask is because I must interface with countless legacy stored procedures with anywhere from 50 to 5000+ lines of code

How to export SQL Server 2005 query to CSV

别等时光非礼了梦想. 提交于 2020-01-09 06:07:15
问题 I want to export some SQL Server 2005 data to CSV format (comma-separated with quotes). I can think of a lot of complicated ways to do it, but I want to do it the right way. I've looked at bcp, but I can't figure out how to put the quotes around the fields (except concatenating them to the field values, which is ugly). I guess I could do it with sqlcmd and -o, but that seems ugly for the same reason. Is there a bcp way to do it? Is there a reasonable sqlcmd way to do it? Is there some great,

How to export SQL Server 2005 query to CSV

ぃ、小莉子 提交于 2020-01-09 06:05:27
问题 I want to export some SQL Server 2005 data to CSV format (comma-separated with quotes). I can think of a lot of complicated ways to do it, but I want to do it the right way. I've looked at bcp, but I can't figure out how to put the quotes around the fields (except concatenating them to the field values, which is ugly). I guess I could do it with sqlcmd and -o, but that seems ugly for the same reason. Is there a bcp way to do it? Is there a reasonable sqlcmd way to do it? Is there some great,

Call sqlcmd commands in stored procedure code

时光怂恿深爱的人放手 提交于 2020-01-06 03:21:46
问题 Because of Linked Server is not easy to send openrowset query I connect to remote Sql Server directly via SQLCMD mode. But this is Ok using Query Analyzer. When I put code to stored procedure I cannot even save it: :Connect x.x.x.x -U sa -P password select * from openrowset('VFPOLEDB','\\share\db\s_object.dbf';''; '','SELECT * FROM s_object where i_class=21 order by 1') Incorrect syntax near ':'. 回答1: sqlcmd mode :connect syntax is valid in SSMS and QA when sqlcmd mode is enabled, but it will

how to make raiserror with nowait work with sqlcmd?

廉价感情. 提交于 2020-01-04 06:38:26
问题 Here is the command line: sqlcmd -S localhost -U myuser -P mypwd -b -r0 -Q "raiserror('hello',10,1) with nowait;waitfor delay '00:00:10';raiserror('world!',10,1) with nowait" It is supposed to output hello immediately and then after 10 seconds world! . Unfortunately, it outputs both strings after 10 seconds. Can sqlcmd do it right? How? P.S. I do not want to use LinqPad or any GUI for that matter. 回答1: I realize this is an old post and there is a high probability that no one will see my

How to encrypt all existing stored procedures of a database

有些话、适合烂在心里 提交于 2020-01-01 03:36:07
问题 Is there any possibility to encrypt all existing stored procedures of a SQL Server 2008 database AFTER they have been created via an SQLCMD script? The reason I want to do this is the following: I'd like to develop the stored procedures without encryption so I can easily click on "Modify" in SQL Server Management Studio to check their contents. However, for the deployment I'd like to encrypt them so I thought that maybe I could write a script which encrypts them only after they're created.

SQLCMD: Prompt for Variable?

元气小坏坏 提交于 2019-12-31 04:50:08
问题 Coming from an Oracle background, Oracle's SQLPlus would let you indicate a variable. If the variable wasn't set, you'd be prompted to provide a value. I'm using SQLCMD, using the $([var_name]) syntax. In SSMS SQLCMD mode, I get: A fatal scripting error occurred. Variable tbl_name is not defined. ...for trying to run: SELECT COUNT(*) FROM $(tbl_name) Does SQLCMD provide the same functionality as SQLPlus? If so, what am I doing wrong? 回答1: SQLCMD does not support prompting for missing variable

Is there any way to generate database scripts from a SQL query in SQL Server?

南笙酒味 提交于 2019-12-31 01:46:13
问题 I need to dump the database structure for a SQL Server database, but I need to do it from a SQL query or sqlcmd script. Is there a valid way to do it? Thanks 回答1: Follow the complete steps to generate script with data. 1 2 3 4 5 回答2: Open object explorer, right click db, tasks, generate scripts, next, script entire databse and all database objects, save to file, next, next, finish. 来源: https://stackoverflow.com/questions/50123959/is-there-any-way-to-generate-database-scripts-from-a-sql-query