Showing posts with label execute. Show all posts
Showing posts with label execute. Show all posts

Monday, March 19, 2012

Compare Substrings

Hello,
I need to check for some records that are different, i
know that they exists but when i execute the following
query a lot of records are sent as result but i expect no
records returned.
I use this query:
select TextData, StartTime, EndTime
from dbo.SpExec
where EventClassDesc = 'SP:Starting' and
(substring(textdata,1,49) <>
substring('declare @.P1 bigint set @.P1=NULL exec
Content_Save',1,49))
When i separate these statements i verify that the output
is exacly the same and is for this reason that i expect no
records in the first query executed.
I put the queries and the results:
1st)
select substring(textdata, 1,49)
from dbo.SpExec
where objectid = xxx and EventClassDesc = 'SP:Starting'
res: declare @.P1 bigint set @.P1=NULL exec Content_Save
2nd)
select substring('declare @.P1 bigint set @.P1=NULL exec
Content_Save',1,49)
res: declare @.P1 bigint set @.P1=NULL exec Content_Save
It seems like the substring function adds an hiden
character in one of the statements that make that the
result is not being the desired result.
I really dont understand what is happening and i
appreciate if you can help me.
Best Regards
Try with:
select TextData, StartTime, EndTime
from dbo.SpExec
where EventClassDesc = 'SP:Starting' and
(substring(textdata,1,49) <>
substring(N'declare @.P1 bigint set @.P1=NULL exec
Content_Save',1,49))
Bojidar Alexandrov
"CC&JM" <anonymous@.discussions.microsoft.com> wrote in message
news:172aa01c4489c$b36909c0$a101280a@.phx.gbl...
> Hello,
> I need to check for some records that are different, i
> know that they exists but when i execute the following
> query a lot of records are sent as result but i expect no
> records returned.
> I use this query:
> select TextData, StartTime, EndTime
> from dbo.SpExec
> where EventClassDesc = 'SP:Starting' and
> (substring(textdata,1,49) <>
> substring('declare @.P1 bigint set @.P1=NULL exec
> Content_Save',1,49))
>
> When i separate these statements i verify that the output
> is exacly the same and is for this reason that i expect no
> records in the first query executed.
> I put the queries and the results:
> 1st)
> select substring(textdata, 1,49)
> from dbo.SpExec
> where objectid = xxx and EventClassDesc = 'SP:Starting'
> res: declare @.P1 bigint set @.P1=NULL exec Content_Save
> 2nd)
> select substring('declare @.P1 bigint set @.P1=NULL exec
> Content_Save',1,49)
> res: declare @.P1 bigint set @.P1=NULL exec Content_Save
> It seems like the substring function adds an hiden
> character in one of the statements that make that the
> result is not being the desired result.
> I really dont understand what is happening and i
> appreciate if you can help me.
> Best Regards
|||Thanks Bojidar, but the result was exacly the same.
Best Regards
>--Original Message--
>Try with:
>select TextData, StartTime, EndTime
> from dbo.SpExec
> where EventClassDesc = 'SP:Starting' and
> (substring(textdata,1,49) <>
> substring(N'declare @.P1 bigint set @.P1=NULL exec
>Content_Save',1,49))
>
>Bojidar Alexandrov
>"CC&JM" <anonymous@.discussions.microsoft.com> wrote in
message[vbcol=seagreen]
>news:172aa01c4489c$b36909c0$a101280a@.phx.gbl...
no[vbcol=seagreen]
output[vbcol=seagreen]
no
>
>.
>
|||If you want an accurate answer, please provide DDL, sample data, and desired
results. Your description of the issue may sound good to you, but it's
difficult to solve a problem based solely on narrative.
http://www.aspfaq.com/5006
http://www.aspfaq.com/
(Reverse address to reply.)
"CC&JM" <anonymous@.discussions.microsoft.com> wrote in message
news:172aa01c4489c$b36909c0$a101280a@.phx.gbl...
> Hello,
> I need to check for some records that are different, i
> know that they exists but when i execute the following
> query a lot of records are sent as result but i expect no
> records returned.
> I use this query:
> select TextData, StartTime, EndTime
> from dbo.SpExec
> where EventClassDesc = 'SP:Starting' and
> (substring(textdata,1,49) <>
> substring('declare @.P1 bigint set @.P1=NULL exec
> Content_Save',1,49))
>
> When i separate these statements i verify that the output
> is exacly the same and is for this reason that i expect no
> records in the first query executed.
> I put the queries and the results:
> 1st)
> select substring(textdata, 1,49)
> from dbo.SpExec
> where objectid = xxx and EventClassDesc = 'SP:Starting'
> res: declare @.P1 bigint set @.P1=NULL exec Content_Save
> 2nd)
> select substring('declare @.P1 bigint set @.P1=NULL exec
> Content_Save',1,49)
> res: declare @.P1 bigint set @.P1=NULL exec Content_Save
> It seems like the substring function adds an hiden
> character in one of the statements that make that the
> result is not being the desired result.
> I really dont understand what is happening and i
> appreciate if you can help me.
> Best Regards

Compare Substrings

Hello,
I need to check for some records that are different, i
know that they exists but when i execute the following
query a lot of records are sent as result but i expect no
records returned.
I use this query:
select TextData, StartTime, EndTime
from dbo.SpExec
where EventClassDesc = 'SP:Starting' and
(substring(textdata,1,49) <>
substring('declare @.P1 bigint set @.P1=NULL exec
Content_Save',1,49))
When i separate these statements i verify that the output
is exacly the same and is for this reason that i expect no
records in the first query executed.
I put the queries and the results:
1st)
select substring(textdata, 1,49)
from dbo.SpExec
where objectid = xxx and EventClassDesc = 'SP:Starting'
res: declare @.P1 bigint set @.P1=NULL exec Content_Save
2nd)
select substring('declare @.P1 bigint set @.P1=NULL exec
Content_Save',1,49)
res: declare @.P1 bigint set @.P1=NULL exec Content_Save
It seems like the substring function adds an hiden
character in one of the statements that make that the
result is not being the desired result.
I really dont understand what is happening and i
appreciate if you can help me.
Best RegardsTry with:
select TextData, StartTime, EndTime
from dbo.SpExec
where EventClassDesc = 'SP:Starting' and
(substring(textdata,1,49) <>
substring(N'declare @.P1 bigint set @.P1=NULL exec
Content_Save',1,49))
Bojidar Alexandrov
"CC&JM" <anonymous@.discussions.microsoft.com> wrote in message
news:172aa01c4489c$b36909c0$a101280a@.phx.gbl...
> Hello,
> I need to check for some records that are different, i
> know that they exists but when i execute the following
> query a lot of records are sent as result but i expect no
> records returned.
> I use this query:
> select TextData, StartTime, EndTime
> from dbo.SpExec
> where EventClassDesc = 'SP:Starting' and
> (substring(textdata,1,49) <>
> substring('declare @.P1 bigint set @.P1=NULL exec
> Content_Save',1,49))
>
> When i separate these statements i verify that the output
> is exacly the same and is for this reason that i expect no
> records in the first query executed.
> I put the queries and the results:
> 1st)
> select substring(textdata, 1,49)
> from dbo.SpExec
> where objectid = xxx and EventClassDesc = 'SP:Starting'
> res: declare @.P1 bigint set @.P1=NULL exec Content_Save
> 2nd)
> select substring('declare @.P1 bigint set @.P1=NULL exec
> Content_Save',1,49)
> res: declare @.P1 bigint set @.P1=NULL exec Content_Save
> It seems like the substring function adds an hiden
> character in one of the statements that make that the
> result is not being the desired result.
> I really dont understand what is happening and i
> appreciate if you can help me.
> Best Regards|||Thanks Bojidar, but the result was exacly the same.
Best Regards
>--Original Message--
>Try with:
>select TextData, StartTime, EndTime
> from dbo.SpExec
> where EventClassDesc = 'SP:Starting' and
> (substring(textdata,1,49) <>
> substring(N'declare @.P1 bigint set @.P1=NULL exec
>Content_Save',1,49))
>
>Bojidar Alexandrov
>"CC&JM" <anonymous@.discussions.microsoft.com> wrote in
message
>news:172aa01c4489c$b36909c0$a101280a@.phx.gbl...
>> Hello,
>> I need to check for some records that are different, i
>> know that they exists but when i execute the following
>> query a lot of records are sent as result but i expect
no
>> records returned.
>> I use this query:
>> select TextData, StartTime, EndTime
>> from dbo.SpExec
>> where EventClassDesc = 'SP:Starting' and
>> (substring(textdata,1,49) <>
>> substring('declare @.P1 bigint set @.P1=NULL exec
>> Content_Save',1,49))
>>
>> When i separate these statements i verify that the
output
>> is exacly the same and is for this reason that i expect
no
>> records in the first query executed.
>> I put the queries and the results:
>> 1st)
>> select substring(textdata, 1,49)
>> from dbo.SpExec
>> where objectid = xxx and EventClassDesc = 'SP:Starting'
>> res: declare @.P1 bigint set @.P1=NULL exec Content_Save
>> 2nd)
>> select substring('declare @.P1 bigint set @.P1=NULL exec
>> Content_Save',1,49)
>> res: declare @.P1 bigint set @.P1=NULL exec Content_Save
>> It seems like the substring function adds an hiden
>> character in one of the statements that make that the
>> result is not being the desired result.
>> I really dont understand what is happening and i
>> appreciate if you can help me.
>> Best Regards
>
>.
>|||If you want an accurate answer, please provide DDL, sample data, and desired
results. Your description of the issue may sound good to you, but it's
difficult to solve a problem based solely on narrative.
http://www.aspfaq.com/5006
--
http://www.aspfaq.com/
(Reverse address to reply.)
"CC&JM" <anonymous@.discussions.microsoft.com> wrote in message
news:172aa01c4489c$b36909c0$a101280a@.phx.gbl...
> Hello,
> I need to check for some records that are different, i
> know that they exists but when i execute the following
> query a lot of records are sent as result but i expect no
> records returned.
> I use this query:
> select TextData, StartTime, EndTime
> from dbo.SpExec
> where EventClassDesc = 'SP:Starting' and
> (substring(textdata,1,49) <>
> substring('declare @.P1 bigint set @.P1=NULL exec
> Content_Save',1,49))
>
> When i separate these statements i verify that the output
> is exacly the same and is for this reason that i expect no
> records in the first query executed.
> I put the queries and the results:
> 1st)
> select substring(textdata, 1,49)
> from dbo.SpExec
> where objectid = xxx and EventClassDesc = 'SP:Starting'
> res: declare @.P1 bigint set @.P1=NULL exec Content_Save
> 2nd)
> select substring('declare @.P1 bigint set @.P1=NULL exec
> Content_Save',1,49)
> res: declare @.P1 bigint set @.P1=NULL exec Content_Save
> It seems like the substring function adds an hiden
> character in one of the statements that make that the
> result is not being the desired result.
> I really dont understand what is happening and i
> appreciate if you can help me.
> Best Regards

Compare Substrings

Hello,
I need to check for some records that are different, i
know that they exists but when i execute the following
query a lot of records are sent as result but i expect no
records returned.
I use this query:
select TextData, StartTime, EndTime
from dbo.SpExec
where EventClassDesc = 'SP:Starting' and
(substring(textdata,1,49) <>
substring('declare @.P1 bigint set @.P1=NULL exec
Content_Save',1,49))
When i separate these statements i verify that the output
is exacly the same and is for this reason that i expect no
records in the first query executed.
I put the queries and the results:
1st)
select substring(textdata, 1,49)
from dbo.SpExec
where objectid = xxx and EventClassDesc = 'SP:Starting'
res: declare @.P1 bigint set @.P1=NULL exec Content_Save
2nd)
select substring('declare @.P1 bigint set @.P1=NULL exec
Content_Save',1,49)
res: declare @.P1 bigint set @.P1=NULL exec Content_Save
It seems like the substring function adds an hiden
character in one of the statements that make that the
result is not being the desired result.
I really dont understand what is happening and i
appreciate if you can help me.
Best RegardsTry with:
select TextData, StartTime, EndTime
from dbo.SpExec
where EventClassDesc = 'SP:Starting' and
(substring(textdata,1,49) <>
substring(N'declare @.P1 bigint set @.P1=NULL exec
Content_Save',1,49))
Bojidar Alexandrov
"CC&JM" <anonymous@.discussions.microsoft.com> wrote in message
news:172aa01c4489c$b36909c0$a101280a@.phx
.gbl...
> Hello,
> I need to check for some records that are different, i
> know that they exists but when i execute the following
> query a lot of records are sent as result but i expect no
> records returned.
> I use this query:
> select TextData, StartTime, EndTime
> from dbo.SpExec
> where EventClassDesc = 'SP:Starting' and
> (substring(textdata,1,49) <>
> substring('declare @.P1 bigint set @.P1=NULL exec
> Content_Save',1,49))
>
> When i separate these statements i verify that the output
> is exacly the same and is for this reason that i expect no
> records in the first query executed.
> I put the queries and the results:
> 1st)
> select substring(textdata, 1,49)
> from dbo.SpExec
> where objectid = xxx and EventClassDesc = 'SP:Starting'
> res: declare @.P1 bigint set @.P1=NULL exec Content_Save
> 2nd)
> select substring('declare @.P1 bigint set @.P1=NULL exec
> Content_Save',1,49)
> res: declare @.P1 bigint set @.P1=NULL exec Content_Save
> It seems like the substring function adds an hiden
> character in one of the statements that make that the
> result is not being the desired result.
> I really dont understand what is happening and i
> appreciate if you can help me.
> Best Regards|||Thanks Bojidar, but the result was exacly the same.
Best Regards
>--Original Message--
>Try with:
>select TextData, StartTime, EndTime
> from dbo.SpExec
> where EventClassDesc = 'SP:Starting' and
> (substring(textdata,1,49) <>
> substring(N'declare @.P1 bigint set @.P1=NULL exec
>Content_Save',1,49))
>
>Bojidar Alexandrov
>"CC&JM" <anonymous@.discussions.microsoft.com> wrote in
message
> news:172aa01c4489c$b36909c0$a101280a@.phx
.gbl...
no[vbcol=seagreen]
output[vbcol=seagreen]
no[vbcol=seagreen]
>
>.
>|||If you want an accurate answer, please provide DDL, sample data, and desired
results. Your description of the issue may sound good to you, but it's
difficult to solve a problem based solely on narrative.
http://www.aspfaq.com/5006
http://www.aspfaq.com/
(Reverse address to reply.)
"CC&JM" <anonymous@.discussions.microsoft.com> wrote in message
news:172aa01c4489c$b36909c0$a101280a@.phx
.gbl...
> Hello,
> I need to check for some records that are different, i
> know that they exists but when i execute the following
> query a lot of records are sent as result but i expect no
> records returned.
> I use this query:
> select TextData, StartTime, EndTime
> from dbo.SpExec
> where EventClassDesc = 'SP:Starting' and
> (substring(textdata,1,49) <>
> substring('declare @.P1 bigint set @.P1=NULL exec
> Content_Save',1,49))
>
> When i separate these statements i verify that the output
> is exacly the same and is for this reason that i expect no
> records in the first query executed.
> I put the queries and the results:
> 1st)
> select substring(textdata, 1,49)
> from dbo.SpExec
> where objectid = xxx and EventClassDesc = 'SP:Starting'
> res: declare @.P1 bigint set @.P1=NULL exec Content_Save
> 2nd)
> select substring('declare @.P1 bigint set @.P1=NULL exec
> Content_Save',1,49)
> res: declare @.P1 bigint set @.P1=NULL exec Content_Save
> It seems like the substring function adds an hiden
> character in one of the statements that make that the
> result is not being the desired result.
> I really dont understand what is happening and i
> appreciate if you can help me.
> Best Regards

Thursday, March 8, 2012

Compare data in tables after inserting?

I'm new to bcp and am trying to import the data from an existing
table into a new table (copied from the existing table).
I ran these:
execute xp_cmdshell 'bcp database.dbo.table out c:\temp\table.txt
-Sserver -T -n'
bulk insert database.dbo.tableA from 'C:\temp\table.txt'
with (DATAFILETYPE = 'native')
Everything seemed to be fine, no error messages. When I ran select
count on the original and the destination, and got very different
values
select count (*) from dbo.table
1140089
select count (*) from dbo.tableA
205272
Why is there such a discrepancy? How should I go about making sure the
data in the tables match, or get them to match, post insert? TIA!Was there existing data in tableA at the time of the import? A count(*) is
a quick way to compare row counts. A more complete solution would be to use
a third-party data comparision tool i.e.,
http://www.red-gate.com/products/SQL_Data_Compare/index.htm .
HTH
Jerry
"nmsm" <naomimsm@.gmail.com> wrote in message
news:1127747561.868201.208900@.f14g2000cwb.googlegroups.com...
> I'm new to bcp and am trying to import the data from an existing
> table into a new table (copied from the existing table).
> I ran these:
> execute xp_cmdshell 'bcp database.dbo.table out c:\temp\table.txt
> -Sserver -T -n'
> bulk insert database.dbo.tableA from 'C:\temp\table.txt'
> with (DATAFILETYPE = 'native')
>
> Everything seemed to be fine, no error messages. When I ran select
> count on the original and the destination, and got very different
> values
> select count (*) from dbo.table
> 1140089
> select count (*) from dbo.tableA
> 205272
> Why is there such a discrepancy? How should I go about making sure the
> data in the tables match, or get them to match, post insert? TIA!
>|||There was no exisiting data in tableA at the time of import, which is
another reason the select difference surprised me.
Is there another way of comparing without a third-party comparison
tool?

Sunday, February 19, 2012

Commit fail and transaction log is full

Hi,

Our testing server experienced a timeout exception when execute System.Data.SqlClient.SqlTransaction.Commit() in SQL Server 2000 thru .Net Framework 1.1. And this happened at 2007-02-13 18:07:05,954.
It was strange to us that all the insert statement can be executed without error within the transaction but the commit operation fails.
Moreover, after about 40 minutes, we found that the transaction log of this database is full.

Here is the exception and SQL Server 2000 Error Log:
Exception Stack Trace:
DateTime: 2007-02-13 18:07:05,954
Req Id: bccdae08-cc47-4f85-8f48-5f0b9dbbbf88
Exception: MyDatabaseException
Detail:
MyDatabaseException:
Index #0
Server: MySQLServer
Source: .Net SqlClient Data Provider
Message: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
LineNumber: 0
Procedure: ConnectionRead (recv()).
State: 0
Error Number: -2 > System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, TdsParserState state)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParser.ReadNetlib(Int32 bytesExpected)
at System.Data.SqlClient.TdsParser.ReadBuffer()
at System.Data.SqlClient.TdsParser.ReadByte()
at System.Data.SqlClient.TdsParser.Run(RunBehavior run, SqlCommand cmdHandler, SqlDataReader dataStream)
at System.Data.SqlClient.SqlInternalConnection.ExecuteTransaction(String sqlBatch, String method)
at System.Data.SqlClient.SqlConnection.ExecuteTransaction(String sqlBatch, String method)
at System.Data.SqlClient.SqlTransaction.Commit()

SQL Server Error Log:

2007-02-13 13:02:23.72 backup Database backed up: Database: MyDatabaseName, creation date(time): 2007/01/12(12:01:39), pages dumped: 944769, first LSN: 9434:22326:1, last LSN: 9434:22360:1, number of dump devices: 1, device information: (FILE=1, TYPE=DISK: {'E:\MSSQL\Backup\MyDatabaseName.bak'}).
2007-02-13 15:50:52.40 backup Database backed up: Database: MyDatabaseName, creation date(time): 2007/01/12(12:01:39), pages dumped: 944970, first LSN: 9442:38096:1, last LSN: 9443:748:1, number of dump devices: 1, device information: (FILE=1, TYPE=VIRTUAL_DEVICE: {'Legato#4f96edfd-7fdb-4cd1-a740-3fe9a54d66c6'}).
2007-02-13 18:48:51.42 spid66 Error: 9002, Severity: 17, State: 6
2007-02-13 18:48:51.42 spid66 The log file for database 'MyDatabaseName' is full. Back up the transaction log for the database to free up some log space..
2007-02-13 18:52:40.61 spid58 Error: 9002, Severity: 17, State: 6
2007-02-13 18:52:40.61 spid58 The log file for database 'MyDatabaseName' is full. Back up the transaction log for the database to free up some log space..
2007-02-13 18:53:22.69 spid61 Error: 9002, Severity: 17, State: 6
2007-02-13 18:53:22.69 spid61 The log file for database 'MyDatabaseName' is full. Back up the transaction log for the database to free up some log space..
2007-02-13 18:54:01.11 spid57 Error: 9002, Severity: 17, State: 6
2007-02-13 18:54:01.11 spid57 The log file for database 'MyDatabaseName' is full. Back up the transaction log for the database to free up some log space..

Are these 2 things related? Would a full transaction log cause a commit operation fail?

Please kindly advice.

Thanks a lot.

the error is self descriptive and the transaction log drive in the machine have no space now. What u need to do now is

(a) Truncate the Log

backup log SomeDatabase with truncate_only

(b) Shrink the log file

dbcc shrinkfile(SomeDatabaseLogicalFileName_Log)

(c) Take FUll Backup -- Very important otherwise the backup chain will break if it is in full recovery

backup database SomeDatabase to Disk='D:\SomeFile.bak' with init

To control the Future growth read the article mentioned below

Refer

http://support.microsoft.com/kb/873235

http://www.databasejournal.com/features/mssql/article.php/1460151

http://www.sql-server-performance.com/forum/topic.asp?TOPIC_ID=6894

Madhu

Sunday, February 12, 2012

Command Line Arguments in Debug mode

Hi,

I am passing some /SET commands on the command line when I execute packages I created in SSIS and have run from the SQL Server Job manager. When I put these same /SET commands on the command line arguments section of the project properties page I would expect they would be passed into the executed package when it is run thru BIDS. But the variables still have their defined values when the packages executes.

Is there a trick to getting command line arguments to work in the debugger for SSIS/BIDS?


DaveM

No, I do not think the application (DTSDebugHost) that runs packages in the debug mode knows how to parse those arguments like DTExec does.

You can simply set those variables inside their window.

Thanks.

|||

Setting the variables inside their window doesn't allow for dynamic selection of values based on runtime values.... which is what I am doing, and trying to test/debug. It works fine except when inside Bids/Visual Studio 2005.

Is this something that will be fixed in SP2 or SP3?

Thanks

|||

DaveM wrote:

Setting the variables inside their window doesn't allow for dynamic selection of values based on runtime values.... which is what I am doing, and trying to test/debug. It works fine except when inside Bids/Visual Studio 2005.

Is this something that will be fixed in SP2 or SP3?

Thanks

SP2 is out and the behavior isn't changed there. I tried it. Seems to me like it should work. The documentation implies that it works the same as dtexec.

From BOL:
CmdLineArguments. Run the package with the specified command-line arguments. For information about command-line arguments, see dtexec Utility.

Friday, February 10, 2012

Comitting statemnts

Hi!
I have a lot of sql scripts in *.sql files.
I'm looking for a solution how to execute them in "one statement" (for
example in Query Analizer) .
Thanks.Query analyzer does not have the ability to read .sql files and execute the SQL code inside those
files. OSQL.EXE does, check out the :r option. But I don't think that you can have GO in those .sql
files.
Another option is to use xp_cmdshell and from there execute OSQL.EXE with appropriate command line
parameters (including name of the .sql file).
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"Dmitry Karneyev" <karneyev@.msn.com> wrote in message news:ONXUBrUnDHA.2652@.TK2MSFTNGP09.phx.gbl...
> Hi!
> I have a lot of sql scripts in *.sql files.
> I'm looking for a solution how to execute them in "one statement" (for
> example in Query Analizer) .
> Thanks.
>|||Thanks for advice!
"Tibor Karaszi" <tibor.please_reply_to_public_forum.karaszi@.cornerstone.se>
ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ:
news:%23XrYmsUnDHA.2536@.tk2msftngp13.phx.gbl...
> Query analyzer does not have the ability to read .sql files and execute
the SQL code inside those
> files. OSQL.EXE does, check out the :r option. But I don't think that you
can have GO in those .sql
> files.
> Another option is to use xp_cmdshell and from there execute OSQL.EXE with
appropriate command line
> parameters (including name of the .sql file).
> --
> Tibor Karaszi, SQL Server MVP
> Archive at:
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
>
> "Dmitry Karneyev" <karneyev@.msn.com> wrote in message
news:ONXUBrUnDHA.2652@.TK2MSFTNGP09.phx.gbl...
> > Hi!
> >
> > I have a lot of sql scripts in *.sql files.
> > I'm looking for a solution how to execute them in "one statement" (for
> > example in Query Analizer) .
> >
> > Thanks.
> >
> >
>|||Hi Tibor ,
We can have "go" in .SQL files and execute this in OSQL / ISQL.
Hi Dmitry Karneyev ,
From Query analyzer u cant do that, instead create a .BAT file
inside the .BAT file , u can call the .SQL files using OSQL / ISQL
eg:
OSQL -Usa -Ppass -Sservername -ic:\a1.sql >out.txt
OSQL -Usa -Ppass -Sservername -ic:\a2.sql >>out.txt
OSQL -Usa -Ppass -Sservername -ic:\a3.sql >>out.txt
Thanks
Hari
MCDBA
"Tibor Karaszi" <tibor.please_reply_to_public_forum.karaszi@.cornerstone.se>
wrote in message news:#XrYmsUnDHA.2536@.tk2msftngp13.phx.gbl...
> Query analyzer does not have the ability to read .sql files and execute
the SQL code inside those
> files. OSQL.EXE does, check out the :r option. But I don't think that you
can have GO in those .sql
> files.
> Another option is to use xp_cmdshell and from there execute OSQL.EXE with
appropriate command line
> parameters (including name of the .sql file).
> --
> Tibor Karaszi, SQL Server MVP
> Archive at:
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
>
> "Dmitry Karneyev" <karneyev@.msn.com> wrote in message
news:ONXUBrUnDHA.2652@.TK2MSFTNGP09.phx.gbl...
> > Hi!
> >
> > I have a lot of sql scripts in *.sql files.
> > I'm looking for a solution how to execute them in "one statement" (for
> > example in Query Analizer) .
> >
> > Thanks.
> >
> >
>|||What Tibor refers to is using the :r options in a input file for osql. :r
allows you pass a list of files to run to osql, for example:
file all.sql
:ra1.sql
:ra2.sql
:ra3.sql
If you now pass the file all.sql as the input file to osql
(OSQL -Usa -Ppass -Sservername -ic:\all.sql), the files a1.sql, a2.sql and
a3.sql will be executed. The drawback of this is that you can't use GO
within the files a1.sql, a2.sql and a3.sql, which is a bummer.
If you use the input .sql files directly with osql you can indeed include GO
in the sql file.
:r is an undocumented option, so we have to take it as it comes I guess.
Jacco Schalkwijk
SQL Server MVP
"Hari" <hari_prasad_k@.hotmail.com> wrote in message
news:ug%23PoAVnDHA.2304@.TK2MSFTNGP11.phx.gbl...
> Hi Tibor ,
> We can have "go" in .SQL files and execute this in OSQL / ISQL.
>
> Hi Dmitry Karneyev ,
> From Query analyzer u cant do that, instead create a .BAT file
> inside the .BAT file , u can call the .SQL files using OSQL / ISQL
> eg:
> OSQL -Usa -Ppass -Sservername -ic:\a1.sql >out.txt
> OSQL -Usa -Ppass -Sservername -ic:\a2.sql >>out.txt
> OSQL -Usa -Ppass -Sservername -ic:\a3.sql >>out.txt
> Thanks
> Hari
> MCDBA
>
>
>
> "Tibor Karaszi"
<tibor.please_reply_to_public_forum.karaszi@.cornerstone.se>
> wrote in message news:#XrYmsUnDHA.2536@.tk2msftngp13.phx.gbl...
> > Query analyzer does not have the ability to read .sql files and execute
> the SQL code inside those
> > files. OSQL.EXE does, check out the :r option. But I don't think that
you
> can have GO in those .sql
> > files.
> >
> > Another option is to use xp_cmdshell and from there execute OSQL.EXE
with
> appropriate command line
> > parameters (including name of the .sql file).
> >
> > --
> > Tibor Karaszi, SQL Server MVP
> > Archive at:
>
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
> >
> >
> > "Dmitry Karneyev" <karneyev@.msn.com> wrote in message
> news:ONXUBrUnDHA.2652@.TK2MSFTNGP09.phx.gbl...
> > > Hi!
> > >
> > > I have a lot of sql scripts in *.sql files.
> > > I'm looking for a solution how to execute them in "one statement" (for
> > > example in Query Analizer) .
> > >
> > > Thanks.
> > >
> > >
> >
> >
>|||> We can have "go" in .SQL files and execute this in OSQL / ISQL.
I never said we can't. I was referring to the :r option of OSQL, See Jacco's explanation (thanks
Jacco!).
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"Hari" <hari_prasad_k@.hotmail.com> wrote in message news:ug%23PoAVnDHA.2304@.TK2MSFTNGP11.phx.gbl...
> Hi Tibor ,
> We can have "go" in .SQL files and execute this in OSQL / ISQL.
>|||My pleasure :)
--
Jacco Schalkwijk
SQL Server MVP
"Tibor Karaszi" <tibor.please_reply_to_public_forum.karaszi@.cornerstone.se>
wrote in message news:eW7gJhVnDHA.2456@.TK2MSFTNGP09.phx.gbl...
> > We can have "go" in .SQL files and execute this in OSQL / ISQL.
> I never said we can't. I was referring to the :r option of OSQL, See
Jacco's explanation (thanks
> Jacco!).
> --
> Tibor Karaszi, SQL Server MVP
> Archive at:
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
>
> "Hari" <hari_prasad_k@.hotmail.com> wrote in message
news:ug%23PoAVnDHA.2304@.TK2MSFTNGP11.phx.gbl...
> > Hi Tibor ,
> >
> > We can have "go" in .SQL files and execute this in OSQL / ISQL.
> >
> >
>|||Thanks guys for explanation!
Since I have "go" in all of my files I decided to do this:
create a "bat" file with following strings
osql -E -S "servername" -d "databasename" -i "sqlfilename"
it works perfect!
"Dmitry Karneyev" <karneyev@.msn.com> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ:
news:ONXUBrUnDHA.2652@.TK2MSFTNGP09.phx.gbl...
> Hi!
> I have a lot of sql scripts in *.sql files.
> I'm looking for a solution how to execute them in "one statement" (for
> example in Query Analizer) .
> Thanks.
>

COMException when execute SQLXMLBulkLoad3Class

I haven't been able to find any information on the error:
"Schema: multiple base for a derived type on when is not supported"
I am trying to run:
Dim bulkLoadObj As New SQLXMLBULKLOADLib.SQLXMLBulkLoad3Class()
bulkLoadObj.Execute(".xsd", ".xml")
If this doesn't work I will need to work on finding a alternative way to get
an xml document into Sql Server.
Thank you for any help provided.
Here is the xsd code for when:
<xs:complexType name="COEvent">
<xs:sequence>
<xs:element name="user" type="COShortUser" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="when" type="CODateOrDateTime"/>
</xs:complexType>
And then at the top of the file
<xs:simpleType name="CODateOrDateTime">
<xs:union memberTypes="xs:dateTime xs:date"/>
</xs:simpleType>
Thanks for any help.
"AshleyT" wrote:

> I haven't been able to find any information on the error:
> "Schema: multiple base for a derived type on when is not supported"
> I am trying to run:
> Dim bulkLoadObj As New SQLXMLBULKLOADLib.SQLXMLBulkLoad3Class()
> bulkLoadObj.Execute(".xsd", ".xml")
> If this doesn't work I will need to work on finding a alternative way to get
> an xml document into Sql Server.
> Thank you for any help provided.
>
|||Hello,
Could you please send me the schema and the data file so i can give it a try?
Thanks,
Monica Frintu
"AshleyT" wrote:
[vbcol=seagreen]
> Here is the xsd code for when:
> <xs:complexType name="COEvent">
> <xs:sequence>
> <xs:element name="user" type="COShortUser" minOccurs="0"/>
> </xs:sequence>
> <xs:attribute name="when" type="CODateOrDateTime"/>
> </xs:complexType>
> And then at the top of the file
> <xs:simpleType name="CODateOrDateTime">
> <xs:union memberTypes="xs:dateTime xs:date"/>
> </xs:simpleType>
> Thanks for any help.
> "AshleyT" wrote:

COMException when execute SQLXMLBulkLoad3Class

I haven't been able to find any information on the error:
"Schema: multiple base for a derived type on when is not supported"
I am trying to run:
Dim bulkLoadObj As New SQLXMLBULKLOADLib.SQLXMLBulkLoad3Class()
bulkLoadObj.Execute(".xsd", ".xml")
If this doesn't work I will need to work on finding a alternative way to get
an xml document into Sql Server.
Thank you for any help provided.Here is the xsd code for when:
<xs:complexType name="COEvent">
<xs:sequence>
<xs:element name="user" type="COShortUser" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="when" type="CODateOrDateTime"/>
</xs:complexType>
And then at the top of the file
<xs:simpleType name="CODateOrDateTime">
<xs:union memberTypes="xs:dateTime xs:date"/>
</xs:simpleType>
Thanks for any help.
"AshleyT" wrote:

> I haven't been able to find any information on the error:
> "Schema: multiple base for a derived type on when is not supported"
> I am trying to run:
> Dim bulkLoadObj As New SQLXMLBULKLOADLib.SQLXMLBulkLoad3Class()
> bulkLoadObj.Execute(".xsd", ".xml")
> If this doesn't work I will need to work on finding a alternative way to g
et
> an xml document into Sql Server.
> Thank you for any help provided.
>|||Hello,
Could you please send me the schema and the data file so i can give it a try
?
Thanks,
Monica Frintu
"AshleyT" wrote:
> Here is the xsd code for when:
> <xs:complexType name="COEvent">
> <xs:sequence>
> <xs:element name="user" type="COShortUser" minOccurs="0"/>
> </xs:sequence>
> <xs:attribute name="when" type="CODateOrDateTime"/>
> </xs:complexType>
> And then at the top of the file
> <xs:simpleType name="CODateOrDateTime">
> <xs:union memberTypes="xs:dateTime xs:date"/>
> </xs:simpleType>
> Thanks for any help.
> "AshleyT" wrote:
>