All Questions
18 questions
-1
votes
1
answer
248
views
Script to change the SQL Default database location in windows
Can someone help me with any script like windows script, BAT script or SQLcmd script for changing the default database location of SQL.
I am using Windows
1
vote
0
answers
429
views
SQL Server command line tool version compatibility with different versions of SQL Servers
I have different versions of SQL Server to whom I need to connect from an EC2 which is based on CentOS. I have sqlcmd downloaded as below:
Microsoft (R) SQL Server Command Line Tool
Version 13.0.0001....
0
votes
1
answer
651
views
sqlcmd utility not showing greek letters
First of all I am using SQL Server 9.00.4035.00 which is SQL Server 2005 SP3.
I am using the below command to fetch the results from a view which fetches rows from a table which includes columns with ...
1
vote
0
answers
1k
views
Permissions Different in SQLCMD and SSMS?
In both cases, I'm logged in using Windows Authentication. My account is a Domain account with the sysadmin role on the SQL Server (2005). I've even verified my sid is the same, by querying SUSER_SID()...
2
votes
0
answers
5k
views
sqlcmd error - HResult 0xFFFFFFFF, Level 16, State 1
I am trying make to make a remote SQL server execute a small .sql file (for now. later, i will try a huge 200 mb.sql file) using sqlcmd (on my client computer). I can easily connect to my server via ...
2
votes
1
answer
940
views
Need help to make sqlcmd run as per requirements
I wanted to run SQLCMD.EXE as mentioned here - http://blog.daringa.com/archives/tag/error-hresult-e_fail-has-been-returned-from-a-call-to-a-com-component
I used the line in link with proper path to ...
1
vote
1
answer
2k
views
Syntax error in SQLCMD SQL script?
I'm currently trying to get a SQL script working for SQL Server 2005. I'm using SQLCMD to execute the script and it fails giving me an "Error: Syntax error at line 7 near command ':r'" error.
The ...
10
votes
2
answers
18k
views
Remove trailing spaces from fixed length in output file generated by sqlcmd
I have a table in SQL Server 2005 with single column of type varchar(500). Data in the column is always 350 characters in length.
When I run a select on it in SSMS query editor, copy & paste the ...
0
votes
1
answer
714
views
i would like to Convert Delimited Text Files To Excel Spreadsheets using SQLCMD in .bat or .sql
Any clues? currently my .bat files is like this.
del *.txt /q
sqlcmd -S TGS-TMS -i c:\scripts\followup.sql -o %date:~10,4%%date:~4,2%%date:~7,2%.csv -s ; -W -u
pause
sendemail -f [email protected] -...
1
vote
3
answers
3k
views
sqlcmd - How to display all the set option setting values
What is the command in sqlcmd to show all the set options and their associated settings?
For example how do you show the current value for nocount?
set
set nocount
set nocount ?
1
vote
1
answer
215
views
dynamic sql sp_executesql works but shoots blanks
Having some fun with t-sql and sp_executesql (test output below). The last piece of the puzzle was the need for sp_executesql to have uppercase N for the query and definition parameters.
I have a ...
3
votes
2
answers
4k
views
sqlcmd not working after installing sql server 2005 express
I downloaded the 53.5 MB setup of SQL Server 2005 Express from this URL:
Microsoft SQL Server 2005 Express Edition
Then I ran sqlcmd by going into command promp , but it shows error
HResult 0x2,...
9
votes
4
answers
6k
views
How to tell if a variable (-v) is defined on command line (SQLCMD)
Is there a way to tell if a variable is defined on command line using SQLCMD?
Here is my command line:
sqlcmd -vDB="EduC_E100" -i"Z:\SQL Common\Admin\ProdToTest_DB.sql"
Inside ProdToTest_DB.sql I ...
15
votes
6
answers
10k
views
sql scripting variable default value
I have a script file e.g. test.sql. I want to call this from another script, say caller.sql, in sqlcmd mode using :r test.sql. This works fine, but I want to use a scripting variable in test.sql. ...
9
votes
6
answers
6k
views
Display DataType and Size of Column from SQL Server Query Results at Runtime
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 ...
22
votes
5
answers
20k
views
SQLCMD, command-line variables and script :setvar
When running SQLCMD.exe and providing command-line arguments for scripting variables, I expect that the values provided on the command-line will override those defined in the SQL script file.
e.g.
...
65
votes
13
answers
188k
views
How to export SQL Server 2005 query to CSV
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 ...
2
votes
2
answers
11k
views
Can't connect to SQL Server Express using sqlcmd.exe
Env.: Vista SP1, SQL Server Express 2005
I'm able to connect to my localhost SQL Server using SQL Server Management Studio, using Windows authentication and, to the best of my knowledge, all default ...