Osql Query Error
Feb 22, 2008
All,
I am facing one problem while running below given query from SSMS or
QA while the same
query running fine while running through osql at command prompt.
while running through command prompt it is giving correct value like
0,1,2 or 3 . With SSMS everytime it is giving null as result.
exec xp_cmdshell 'osql -S SMOSVR0686 -E -Q"declare @test int
Exec master..xp_regread @rootkey = ''HKEY_LOCAL_MACHINE'',@key =
''SOFTWAREMicrosoftMSSQLServerMSSQLServer'',@val
ue_name = ''AuditLevel'',@value=@test OUTPUT select @test"'
p.s - while running at command prompt please remove extra quotes..
Any help is much appreciated
nj
View 1 Replies
ADVERTISEMENT
Apr 21, 2004
Locally executing osql to create db files on a remote Webserver, I get this error:
41> 42> 43> 44> 45> Meldung 916, Ebene 14, Status 1, Server USER-EQ9OV60EMF, Zeile 12
Server user 'Robse_Testlogin' is not a valid user in database 'msdb'.
(The above is german and translates into "Message 916, Level 14,..., Row 12")
This is the command with parameters:
osql -S servername -U Robse_Testlogin -P password -i c:Storestoredb.sql"
Up to that line, everything works fine...what could be wrong?
View 3 Replies
View Related
Dec 10, 2007
Hi All,
The command showed below provides the output shown:
set @cmd = 'osql -S bcgsql1cgsqldev -U checkdb -P checkdb -q "set nocount on; select errorlogdesc from ##errors where datediff(dd,errorlogdatetime,getdate()) = 1 and errorlogdesc like ''%Error:%''" -h-1 -w 900 -o J:ScriptsTestStuffErrorLogMsg.txt'
Here is the output:
Error: 17883, Severity: 1, State: 0
Error: 17883, Severity: 1, State: 0
I need to remove the space between the two lines so I set the -w parameter to 900 but that didn't fix it. Any idea how I can accomplish this?
Thanks
View 4 Replies
View Related
Jun 12, 2006
I'm running a query with osql, and I'm trying to get some clean output that is comma delimited. So far my line looks like this:osql -E -n -d mydb -i custom.qry -o "c:output
esults.csv" -h-1 -s ","This works off a table with only two columns. I'm still left with a lot of extra spaces between the first column output and second column output, and at the bottom the text "(50 rows affected)".So instead of this:data1a (lots of spaces here) ,data1bdata2a (lots of spaces here) ,data2bdata3a (lots of spaces here) ,data3b(50 rows affected)I want to see this:data1a,data1bdata2a,data2bdata3a,data3bThanks very much for any help. :)
View 2 Replies
View Related
Jul 23, 2005
Hello,I have the following problem.I wrote a batch file that runs a sql script on SQLServer 2000. Thisscript must be executed on several databases. This works fine.The problem is that in my database is a table that holds a databases ihave to update with this script. What i want is run a query with osqlin my batchfile to retrieve this these records so I can loop throughthem an run the script for those databases.I managed to execute the query that return the records and write themto a textfile.What i want is store the results in some kind of a resultset so i canloop through them in my batchfile.Anyone have the solutionThanks in advancePatrick
View 1 Replies
View Related
Jul 23, 2005
How can I create a new database on sql server using OSQL command incommand prompt. I have the sql file for database creation and I use thefollowing commandC:> osql -S servername -U sa -i db1.sqlit prompt my for password n i enter it since sa has a blank passwordbut after that it returns the following error.1> 2> 3> Msg 170, Level 15, State 1, Server servername, Procedure ,Line 2[Microsoft][ODBC SQL Server Driver][SQL Server]Line 2: Incorrectsyntax near 'COLLATE'.1> 2> 3> Msg 15010, Level 16, State 1, Server servername, Proceduresp_dboption, Line 95[Microsoft][ODBC SQL Server Driver][SQL Server]The database'db1' does not exist. Use sp_helpdb to show available databasesCan anyone help me on that?
View 3 Replies
View Related
Nov 10, 2003
I have the following .bat file that I call to register users to my MSDE instance...
echo osql -E -S %COMPUTERNAME%OfficiumInstance -Q "sp_grantlogin '" + %COMPUTERNAME% + "ASPNET'"
echo osql -E -S %COMPUTERNAME%OfficiumInstance -d Officium -Q "sp_grantdbaccess '" + %COMPUTERNAME% + "ASPNET'"
echo osql -E -S %COMPUTERNAME%OfficiumInstance -d Officium -Q "sp_addrolemember 'db_owner', '" + %COMPUTERNAME% + "ASPNET'"
My question is how do I correctly append %COMPUTERNAME% as a string to
I have tried using + signs...
"sp_grantlogin '" + %COMPUTERNAME% + "ASPNET'"
But that doesn't work.
I have looked for .bat file tutorials on the web but can't find the correct way to do this.
Greg
View 1 Replies
View Related
May 16, 2007
Hello,
I get following error trying to use SQLCMD OR OSQL
Named Pipes Provider: Could not open a connection to SQL Server [2].
Sqlcmd: Error: Microsoft SQL Native Client : An error has occurred while establi
shing a connection to the server. When connecting to SQL Server 2005, this failu
re may be caused by the fact that under the default settings SQL Server does not
allow remote connections..
Sqlcmd: Error: Microsoft SQL Native Client : Login timeout expired.
I searched this forum for answers and I found one solution where it was said that Remote connections for TCP and Named Pipes needs to be enabled. I have them enabled, but I still get this error. I had working SQL server before, but I had to uninstall it. Now after installing ti again I started to get this error.
Anything else besides disabled remote connections cause this problem? I'm trying a local connection. I heard elsewhere that this could be firewall related, but shouldn't it use local connection always when I try to connect it with sqlcmd and no other parameters given?
View 2 Replies
View Related
Oct 7, 2004
I have a process that is running on the os. This process is picking up FTP files every 5 min, it renames them so not to confuse them with the new files, copies all renamed files into one file to be used by bulk insert, runs the bulk insert to populate a table, and then runs the stored procedure that scrubbing the data and insert it into another table. For every transaction that I do in my stored procedure, I do the error checking as follows:
IF @@error <> 0
BEGIN
ROLLBACK TRANSACTION
RETURN
If my stored procedure encounters an error, return statement will stop it from running. If this happens, I need to stop the process that is running on the os as well.
Questions:
How can that be accomplished?
How to restart the stored procedure ones the error has been corrected?
Thank you for your help.
View 3 Replies
View Related
Jan 22, 2001
Hi,
I get this error dialog when I try to open all the rows of any table from Enterprise manager..
Any help would be really appreciated..
Thanks,
-Srini.
View 1 Replies
View Related
May 24, 2007
SQL Server 2005 9.0.3161 on Win 2k3 R2
I receive the following error:
"Error: 8624, Severity: 16, State: 1 Internal Query Processor Error: The query processor could not produce a query plan. For more information, contact Customer Support Services."
I have traced this to an insert statement that executes as part of a stored procedure.
INSERT INTO ledger (journal__id, account__id,account_recv_info__id,amount)
VALUES (@journal_id, @acct_id, @acct_recv_id, @amount)
There is also an auto-increment column called id. There are FK contraints on all of the columns ending in "__id". I have found that if I remove the contraint on account__id the procedure will execute without error. None of the other constraints seem to make a difference. Of course I don't want to remove this key because it is important to the database integrity and should not be causing problems, but apparently it confuses the optimizer.
Also, the strange thing is that I can get the procedure to execute without error when I run it directly through management studio, but I receive the error when executing from .NET code or anything using ODBC (Access).
View 5 Replies
View Related
Jun 30, 2000
When I am trying to read rows from any table from any database in the offsite production
server with Pc Anywhere ( all other servers can be acess fine with pc anywhere
I get this error
An unexpected error happned during this operation
{query} query designer error encountered a query error
unexpected error
I checked the version of Enterprise manager
Help
About
microsoft managment console 1.1version 4.0 bulid 1381
service pack 4
View 1 Replies
View Related
Jun 28, 2001
Hi, we are having problems getting osql to work. When we try and open it quickly opens and then closes again. Has anybody else had this problem?
View 1 Replies
View Related
Oct 25, 2004
Hi all.
My first post here.
I want to distriburte a msde database. When doing so, I also want to make a new login, make a user, make the user the dbowner of the database i installed.
I found the Stored procedures I need to use, and I have tested that it works using OSQL.
What I want to do now is to make this automatic. After installing the database the OSQL commands should be executed and no user interference should be necessary. How can that be done ?
peet
View 4 Replies
View Related
May 15, 2008
Hi All,
I am trying to use OSQL (somthing I am new too)
I have the folllowing syntax, but it does not seam to work. Any ideas would be very gratfull.
osql -Usa -Ppassword -SServername -Q"select @@version"
Thanks in advance
Dave
Dave Dunckley says there is a law for the rich and a law for the poor and a law for
Dirty Davey.
View 7 Replies
View Related
Mar 11, 2008
Hello,
I have several sql scripts to be executed on a set schedule, with the output directed to a text file. If the schedule triggers this process daily, is it possible to append each days output to the same output file? I've researched the osql switches and various online sources...nothing really covers this.
This is done (relatively) easily with .vbs, but so far it looks tougher with TSQL.
Many thanks to all who respond!
View 2 Replies
View Related
Mar 12, 2008
is there some way to activate osql from a c++ app and stream theoutput to my program?
View 1 Replies
View Related
Dec 22, 2006
i'm trying to execute some scripts created by the express studio script wizard. i can connect with the studio, the website (asp worker) but i can't create the right cmdline for osql ..... this is my osql line ......
C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLBinn>osql -S (local)\SQLEXPRESS -U sa -P sablah -i run.sql.......
this is the error i'm getting in my logs
Error: 18456, Severity: 14, State: 16.
2006-12-22 15:30:45.11 Logon Login failed for user 'sa'. [CLIENT: <local machine>]
"Server=(local)\SQLEXPRESS;Database=ggmi;User Id=sa;Password=cr79cr02;Trusted_connection=false;";
the following is the working connection string for my aspworker.
"Server=(local)\SQLEXPRESS;Database=ggmi;User Id=sa;Password=cr79cr02;Trusted_connection=false;";
when i try to put in the trust conenction parameter is says that it conflicts with the user flag ,. probably because its a differant type of login process. any ideas?
View 6 Replies
View Related
Jul 28, 2004
using osql utility i have converted a table in database to excel format. I have also chinese data in my database . The problem is while converting the data into excel format ,the chinese data is not comming in excel sheet.
Does anybody have an idea about this .
For converting i have used
declare @x varchar(300)
set @x = 'osql -S Servername -U username -P passwd -q "select * from northwind..region order by cand_index" -w 3000 -s "," -o C:directoryfilename.csv'
Thanks
View 2 Replies
View Related
Aug 14, 2004
Hi all
I am using osql utility in sql server 2000 to convert data in database to excel sheet. My datas contain both english and chinese . While converting to excel sheet english datas are comming but the datas in chinese is comming like (?) this. Does any body has any idea to solve this problem. is there any way to set font in osql utility.
set @x = 'osql -S servername -U username -P password -q "select * from
northwind..region" -w 3000 -s "," -o C:Downloaddownload.csv'
This is what i have used.
Note: I tried giving chinese font in excel still it is not working.
Its really urgent pls reply
thanks
View 2 Replies
View Related
Oct 8, 2004
Dear friends,
I was trying to run this script from a dos batch file under win xp but it's not working. Please help with the syntax.
================================================== =======
OSQL -U sa -P samsde -S firebird /Q "RESTORE DATABASE NAVIMEX FROM DISK = 'C:30704' WITH
REPLACE, MOVE'NAVIMEX_Data' TO 'C:Program FilesMicrosoft SQL
ServerMSSQLDataNAVIMEX_Data.MDF',MOVE 'NAVIMEX_Log' TO 'C:Program FilesMicrosoft SQL
ServerMSSQLDataNAVIMEX_LOG.LDF'" QUIT
================================================== ========
Please provide me with the correct syntax to be put in a 'restore.bat' file :rolleyes:
Thanks in advance.
HotBird
View 4 Replies
View Related
Oct 25, 2004
the help document said that
"osql -b will specifies that OSQL exits and returns a DOS ERRORLEVEL value when an error occurs. The value returned to the DOS ERRORLEVEL variable is 1 when the SQL Server error message has a severity of 10 or greater; otherwise, the value returned is 0."
my question is : how can I get the DOS ERRORLEVEL.
example:
C:>isql -E -b -Q"backup log pubs to disk='C:adsfasd.tmp'"
the result:
Msg 4208, Level 16, State 0, Server YANG, Line 1
当恢复模型为 SIMPLE 时,不允许使用 BACKUP LOG 语句。请使用 BACKUP DATABASE 或用
ALTER DATABASE
更改恢复模型。
Msg 3013, Level 16, State 1, Server YANG, Line 1
BACKUP LOG 操作异常终止。
It's in chinese language,means
"can not use BACKUP LOG when the restore model being SIMPLE,you can use ALTER DATABASE or BACKUP DATABASE to change the restore model.
Msg 3013, Level 16, State 1, Server YANG, Line 1
BACKUP LOG aborted"
where is DOS ERRORLEVEL???? How can I get it????
thanks
View 2 Replies
View Related
Dec 1, 2004
Hello All,
A VERY green SQL Server DBA here looking for some help. Our main production environment is Oracle, which utilizes Control-M as a scheduler. At the end of the Oracle batch process, we would like to automate a process to kick off a sql server job (perhaps via osql??) Is this possible?
Thanks in advance,
Tony
View 14 Replies
View Related
Dec 14, 2005
I run a script with Osql and got no error but the accent caracter (french message) are modified.
the script is
CREATE PROCEDURE dbo.AccentTest
AS
Print('é à è î ï ù')
GO
and come
CREATE PROCEDURE dbo.AccentTest
AS
Print('Θ α Φ ε ∩ ∙')
GO
:o
This is very bad! Can someone can help me?
Any suggestion?
PLease.....
osql.exe -S MyServer -U username-P pwd-d TestDB -n -o "C:Devosql_test.log" -i "C:DevAccentTest.sql" :
View 1 Replies
View Related
Sep 5, 2006
Question for the experts here:
Is there any advantage of running an SQL statement through osql with the database information over using dynamic sql?
Example:
DECLARE @DB Varchar(50)
DECLARE @SQL Varchar(4000)
SET @DB = '<nvr_changing_server>.<my_dynamic_db_name>'
SET @SQL = 'SELECT admissiontype_id AS atype, admissiontype AS atype_desc, start_date, end_date
INTO tlkAdmitType
FROM <nvr_changing_server>.<nvr_changing_DB>.dbo.tlkAdmissionTypes'
exec master..xp_cmdShell 'osql -U sa -P sapwd -S nvr_changing_server -d my_dynamic_db_name -Q @SQL....'
vs. something like:
DECLARE @DB Varchar(50)
DECLARE @SQL Varchar(4000)
SET @DB = '<nvr_changing_server>.<my_dynamic_db_name>'
SET @SQL = 'SELECT admissiontype_id AS atype, admissiontype AS atype_desc, start_date, end_date
INTO ' + @DB +'.dbo.tlkAdmitType
FROM <nvr_changing_server>.<nvr_changing_DB>.dbo.tlkAdmissionTypes'
EXEC(@SQL)
The purpose of all this is...I need to pass a parameter for the DB that I will be inserting into...here we create a new db with a specific name based on quarterly data. We collect, crunch, validate data and ship it. Then when it's old we archive it then eventually delete it.
I have written a script that makes this quarterly build less painful. In fact I won't have to do it! :)...our Sr. Data Analysts will do it now. In order for this beautiful thing (*in my mind anyway*) to work they need to set parameters for which data to pull and where to put it. The DB is scripted into existance and the data is moved into it. So therefore they need to enter the Qtr,Yr and dbname. I have done DSQL before on smaller scripts and I am just curious if the expert pool here can shed some light on this approach. The script will most likely be run in a DTS SQL Task.
Thanks in advance...R
View 1 Replies
View Related
Feb 25, 2004
Hi,
When i want to run the OSQL utility, it will open the command prompt, but only for about a second, then, gone...
I'm running an XP pro machine with MSDE 2000 installed locally... any ieads??
thanks!
View 2 Replies
View Related
Mar 18, 2004
I created a sql script that transfers data from my test system to production adn vice versa. I would like to use OSQL and be able to pass parameters to the SQL script.
Example: param 1 = test; param 2 = production.
Can anyone tell me if this is possible and how to do it?
Thanks in advance for all the help.
View 2 Replies
View Related
May 5, 2004
At first I'd like to justify myself - I'm rather a greenhorn in MS SQL ;-)
What I'd like to do is to create a very simple spool file from my database.
I'd like to do this using OSQL tool and it's very important for me to have the spool file in the same format as it was earlier when I used Oracle and simple spool command.
And it's almost the same, but white spaces...
There's always one white space at the begining of each line and at least one at the and of each line.
I've been trying many OSQL switches and ltrim(..) / rtrim(..) functions but the problem still exists...
The spool file is rather big - around 300MB so it's not good idea to use SED (for example) to remove white spaces.
So my question:
IS IT POSSIBLE TO REMOVE WHITE SPACES COMPLETELY USING OSQL SPOOL?
Thanks in advance for any help.
View 9 Replies
View Related
Jan 17, 2008
Is osql/isql supported in SQL 2005? How about in 2008? Thanks
View 2 Replies
View Related
Jul 23, 2005
Hi,I have several big tables with rows more than 25 mil rowsand to update/delete/insert data in these tables,it can take minutes.I use BULK Insert/DELETE/Update with osql.While I run one of these updates,if I try to select, it seems like both read and write get locked.Shouldn't SQL resolve this kind of locking?I left these to see if it gets resolved but both never returned.So I need to kill these processes.Does anyone have any scripts to find how long queries are running?Also I need to make osql timeout and tried -t but it didn't work.I used -t 1200 with DELETE in osql but it was running for more than 40minutes. So I killed it and ran DBCC DBREINDEX on the table and re-ranit and it worked.Shouldn't the query get killed after 10 minutes?What is exactly -t option for ?thanks,
View 2 Replies
View Related
Jul 23, 2005
I have some long running scripts which I fire at my database using osql.(These are big files and mostly doing inserts but some also do a few otherthings.) It would be nice to have some activity indication (other than thedisk activity light) that these are running. When I used to use Oracle,their equivalent to osql had an option to print a dot (without a carriagereturn) for every "n" statements. This gave a nice "I'm alive" indicator. Ican simulate this by adding a few "print" statements in my sql, but printalways adds a carriage return. Does anyone know a way of doing a print butwithout the addition of a CR (or CR/LF)? So that a second "print" sends itsoutput to the same line as the first?I know this is a nicety and I can live without it, but it would be nice.thanks in advance,Brianwww.cryer.co.uk/brian
View 4 Replies
View Related
Mar 21, 2006
I have a question. I am doing some work for someone and I have a batchfile that they can run that will execute an OSQL line and a DTSRUNline. In both lines I run them using the /S /U /P switches and ofcourse the /N or /i switch to tell it what to run. I have also triedreplacing the /U /P switches with the /E switch.My problem is that as long as I specify the users password on the OSQLline (either with /U & /P or with /E & /P) it will run. If I try andjust use the /E it will say password failed for DOMAIN/USER . Ok, Idon't really care I can specify the password and the script will run.However no matter what I do the DTSRUN line will not run, it gives methis same password error.I can run this line just fine on my PC on my network and my domainusing just the /S /E switches.Any ideas as to why it will work for OSQL but not DTSRUN?Thanks in advance.
View 5 Replies
View Related
Feb 1, 2008
I find this thread very useful. But how can I run those scripts in command line using OSQL???
View 5 Replies
View Related