All Questions
Tagged with sqlcmd sql-server-2008-r2
20 questions
0
votes
1
answer
66
views
Query to SQL Server 2008 R2 with nested function call succeeds in SSMS but fails using ODBC
I have a legacy database that is running SQL Server 2008 R2 Express Edition.
Today, I was trying to use sqlacodegen to generate SQLAlchemy classes via the pyodbc package. I was able to connect to the ...
0
votes
1
answer
2k
views
SQLCMD.exe window is not opening
On Windows Server 2012 we have SQL Server 2008-R2 Enterprise installed that does have SQLCMD but when I try to open the utility its black console window opens for a fraction of a second and then ...
1
vote
1
answer
1k
views
setvar - Incorrect syntax near 'dbname'
I've searched for the answer for this but all I can see is answers to "incorrect syntax near ':'" which is easily solved by turning on SQLCMD mode.
But once I've turned that on I get another error:
...
2
votes
0
answers
306
views
SQLCMD in T-SQL with SQLCMDHEADERS -1 Not working in SQL Server 2008R2
Been looking around, can't find an answer to my problem.
I am using a SQLCMD script, within T-SQl. So i start the script from SQL Server Management Studio and select the SQLCMD mode.
I use the ...
1
vote
0
answers
2k
views
Database connection fails when connecting using sqlcmd with encrypt connection
I am trying to connect to sql server with forced encryption using sqlcmd.
I have added a certificate to sql server and enabled forced encryption.
But the sqlcmd tool is not able to connect to the ...
0
votes
2
answers
4k
views
Why is my powershell output file blank?
Sorry, I'm new to Powershell so I'm obviously missing something fairly fundamental but I can't seem to figure this out.
I've got a powershell script calling a SQL script. I can get the script to run ...
1
vote
1
answer
2k
views
Cannot run Invoke-Sqlcmd in a PS1 file but can on the console
I'm currently on a machine with SQL server 2008 and according to this question (How to execute .sql file using powershell?), I've installed the powershell snapins to interact with SQL server.
The ...
1
vote
2
answers
2k
views
using sqlcmd script my linked server queries fail to connect
My stored procedure in SQL Server 2008 R2 runs queries on several local and several remote databases (via linked servers) and works fine when I exec it while in SSMS.
When I run the same exec from a ...
0
votes
2
answers
10k
views
create Scheduler task to invoke SQLCMD
I have a Requirement where i have to run a SQL Script in SQL server on a weekly basis .Result of this script has to be mailed.I want to automate this process.I don't want to go with SSIS Jobs. I have ...
0
votes
2
answers
1k
views
SQL Login Properties - User Mapping
Of course I can use SMS to check the box below... but how would I do it with a script or from SQLCMD?
0
votes
1
answer
505
views
Create Multiple Connections from bat file
What I'm trying to do is to simulate a 50-60 connections querying the same statement.
I created a batch file and can successfully call the .sql file within (sqlcmd).
The next step would be to adjust ...
0
votes
1
answer
1k
views
How to run a SQL Server 2008 R2 Database Script using sqlcmd in C#?
i am new to run SQL Scripts using sqlcmd in C#. i saw some code in Internet but i am not understanding how it Works.
string path = string.Empty;
OpenFileDialog opd = new OpenFileDialog();
...
0
votes
1
answer
2k
views
SELECT OBJECT_DEFINITION(object_id) FROM sys.objects returns NULL for Tables only
Using the following sp I plan to export my object definitions to text files, and then import them into SVN. The sp works fine for stored procedures and views. However, when used for user tables it ...
0
votes
1
answer
3k
views
Loop through a list of databases and run SQL file(s)
I have a number of databases on which I should run the same SQL file. The database names can be found in a table in another database. I was wondering if I can automate this somehow to avoid changing ...
4
votes
1
answer
11k
views
Issue with SQL install and sqlcmd in same .bat file
I am trying to use a single .bat file to:
1) install SQL Server 2008 R2 Express from SQLEXPR_x64_ENU.exe on Windows 7 Professional 64-bit machines, and
2) run some .sql scripts once the install is ...
4
votes
3
answers
28k
views
Can't access sqlcmd using username password
I am new to SQL Server. Please help me to fix.
I have created a user with password in SQL Server Management Studio (2008 R2). When I use sqlcmd with this user, sqlcmd says
C:\Console2>sqlcmd -U ...
0
votes
0
answers
691
views
Attaching SQL Server 2008 R2 Express database via C#
I am having trouble attaching a SQL Server 2008 R2 Express database. I have to do it via a .Net exe.
Here is my code
string fileName = @"C:\express\createdb.sql";
ProcessStartInfo psiSqlCmd = new ...
1
vote
2
answers
863
views
way to execute different folders' scripts using one bat file from one location
I have to execute a bulk of scripts on sql server 2008r2.These scripts are present in many folders and subfolders.I created a batch file to execute these scripts but my problem is i have to put this ...
0
votes
1
answer
3k
views
cannot make sqlcmd work after runas
I followed a few examples here, but I still can not get my sqlcmd work after runas.
I can make it work with two steps:
Step one: Use runas to login into a new login and open a command prompt:
...
13
votes
3
answers
36k
views
How to get SQLCMD to output errors and warnings only
How can you get SQLCMD, when executing a SQL script file, to just output any errors or warnings it encounters?
I essentially dont want information based messages to be output.