Showing posts with label create. Show all posts
Showing posts with label create. Show all posts

Friday, March 30, 2012

Output Buffer Remove Row?

I am using a script component to create the output buffer dynamically. I use the Outputbuffer.AddRow() call. I then set all the fields I want, and its added to the output and later inserted into the database. If a field value fails it causes an error, but the record is partially inserted upto the point where the set field command caused the error. So if I set 10 fields, and it fails on field 5 it inserts data for the 5 fields that worked and nulls into the others.

As a result I have a try catch clause, and if it fails I want to cancell the addition of the new row. Is there a command like RemoveRow(), rollback, etc that can be used to not insert the record in error?

Sample code..

Try

PaymentOutputBuffer.AddRow()

PaymentOutputBuffer.Sequence = pi + 1

PaymentOutputBuffer.RecordID = Row.RecordID

PaymentOutputBuffer.PaymentMethod = PaymentArray(pi)

Catch e As Exception

PaymentErrorOutputBuffer.removecurrentrow(?)

End Try

Can you provide more of your script? Maybe even all of it?|||

The script is very long. I do the same basic task in three scripts for three different feeds, this is the shortest one. The only difference (basically) between this and the others is the number of field in the outputbuffer. Ok.. Here is the code:

Imports System

Imports System.Data

Imports System.Math

Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper

Imports Microsoft.SqlServer.Dts.Runtime.Wrapper

Imports System.Text

Imports Company.SSIS.Functions

Public Class ScriptMain

Inherits UserComponent

Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)

Dim PaymentRecord As String = System.Text.Encoding.Unicode.GetString(Row.PaymentMethods.GetBlobData(0, CInt(Row.PaymentMethods.Length)))

Dim PaymentArray() As String

Dim pi As Integer

PaymentArray = Parse.StringParse(PaymentRecord, "\|")

For pi = 0 To PaymentArray.Length - 1

If PaymentArray(pi) <> "" Then

Try

PaymentOutputBuffer.AddRow()

PaymentOutputBuffer.Sequence = pi + 1

PaymentOutputBuffer.ServiceRecordID = Row.ServiceRecordID

PaymentOutputBuffer.PaymentMethod = PaymentArray(pi)

Catch e As Exception

PaymentErrorOutputBuffer.AddRow()

PaymentErrorOutputBuffer.ErrorRecordID = Row.ServiceRecordID

PaymentErrorOutputBuffer.ErrorCode = e.Message

PaymentErrorOutputBuffer.ErrorData.AddBlobData(Encoding.UTF8.GetBytes(PaymentArray(pi)))

End Try

End If

Next

End Sub

End Class

The Company.SSIS.Functions import is a dll I wrote. It has the Parse.StringParse(PaymentRecord, "\|") call. It is simply a regex function. I listed it below.. but basically splits the delimited field into multiple rows. So the goal is that it is called per row, splits the data in the row into an array and stores it as records. If the paymentmethod store fails, the record still gets inserted into the datase with the sequence and service record id. The catch directs creates a second output, that i then store to my error table. I essentially want the catch to still send to my error table, but for the first output not to be created if it fails and enters the catch.

Public Class Parse

Public Shared Function StringParse(ByVal StringValue As String, ByVal ParseValue As String) As String()

If Replace(StringValue, "", Nothing) Is Nothing Then

Return Split(StringValue)

Else

Dim pattern As String = ParseValue & "(?=(?:[^""]*""[^""]*"")*(?![^""]*""))"

Dim r As RegularExpressions.Regex = New RegularExpressions.Regex(pattern)

Return r.Split(StringValue)

End If

End Function

End Class

|||What are some of the reasons why the assignment to PaymentMethod could fail?|||

Payment method is varchar(20) field. The output is defined as String 20. Primary reason of failure is text truncation. On other code it may be bad date/time stamp, non integer value, etc. Typically it is a data error.

I can do a specific check on payment method to make sure its not in error before calling the addrow() so that the output is not called unless it will succeed. But for scenarios I don't think of, or conditions where I need to check 20+ fields this is not as practical. So I was hoping to use a try/catch process to insert the row if its good, otherwise write to the error table.

|||Yep, I hear ya... I just wanted you to think about performing data validation up front, and you have. Good.

Some of the other code experts may have to chime in now. |||Remove the current row with the call to the PipelineBuffer.RemoveRow() method. The script component does not expose the PipelineBuffer.RemoveRow() method directly, but its does expose the PipelineBuffer(s) in PrimeOutput, on which RemoveRow can be called.

Taking your scenario as example, save the underlying pipeline buffers, and call any PipelineBuffer method on them, including RemoveRow.

Imports System

Imports

Microsoft.SqlServer.Dts.Pipeline

Public Class ScriptMain

Inherits

UserComponent

Private

normalBuffer As PipelineBuffer

Private

errorBuffer As PipelineBuffer

Public Overrides Sub

Input0_ProcessInputRow _

(ByVal

Row As Input0Buffer)

Try

With

PaymentOutputBuffer

.AddRow()

.FirstString =

Row.GeneratedStr1

End

With

Catch

ex As Exception

With

PaymentErrorOutputBuffer

.AddRow()

.ErrorMessage =

ex.Message.Substring(0, _

Math.Min(ex.Message.Length,

250))

End

With

normalBuffer.RemoveRow()

' Remove

the row from normal, as normalBuffer

' is the

underlying PipelineBuffer

' for

PaymentOutputBuffer

End Try

End Sub

Public Overrides Sub

PrimeOutput(ByVal Outputs As Integer, _

ByVal

OutputIDs() As Integer,

_

ByVal

Buffers() As

Microsoft.SqlServer.Dts.Pipeline.PipelineBuffer)

' save

underlying PipelineBuffer to allow for calls to

'

PipelineBuffer methods

normalBuffer = Buffers(0)

errorBuffer = Buffers(1)

MyBase.PrimeOutput(Outputs,

OutputIDs, Buffers)

End Sub

End Class

|||Thanks.. .that works and does what I need. I was curious about the Buffers(x) value and if there is another way to set it to the specific outputbuffer. I tried to look at the help on the Pipeline buffer, but was not able to determine it. I want to be able to reference the Buffers(PaymentOutputBuffer) vs. a 0 so that if people add additional buffers, etc it will not break. Is there a way to make this go off the actual buffer name?|||Yes, the buffers can be referenced by name.

The OutputIDs array parameter to PrimeOutput has the integer buffer ids (not the offset) in coordinated order with the Buffers array.

The buffer's name is available via a call to ComponentMetaData.OutputCollection.FindObjectById(<id from OutputIds here>).Name.

See the following BOL reference for the OutputCollection methods: ms-help://MS.VSCC.v80/MS.VSIPCC.v80/MS.SQLSVR.v9.en/dtsref9mref/html/T_Microsoft_SqlServer_Dts_Pipeline_Wrapper_IDTSOutputCollection90_Members.htmsql

Output Buffer Remove Row?

I am using a script component to create the output buffer dynamically. I use the Outputbuffer.AddRow() call. I then set all the fields I want, and its added to the output and later inserted into the database. If a field value fails it causes an error, but the record is partially inserted upto the point where the set field command caused the error. So if I set 10 fields, and it fails on field 5 it inserts data for the 5 fields that worked and nulls into the others.

As a result I have a try catch clause, and if it fails I want to cancell the addition of the new row. Is there a command like RemoveRow(), rollback, etc that can be used to not insert the record in error?

Sample code..

Try

PaymentOutputBuffer.AddRow()

PaymentOutputBuffer.Sequence = pi + 1

PaymentOutputBuffer.RecordID = Row.RecordID

PaymentOutputBuffer.PaymentMethod = PaymentArray(pi)

Catch e As Exception

PaymentErrorOutputBuffer.removecurrentrow(?)

End Try

Can you provide more of your script? Maybe even all of it?|||

The script is very long. I do the same basic task in three scripts for three different feeds, this is the shortest one. The only difference (basically) between this and the others is the number of field in the outputbuffer. Ok.. Here is the code:

Imports System

Imports System.Data

Imports System.Math

Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper

Imports Microsoft.SqlServer.Dts.Runtime.Wrapper

Imports System.Text

Imports Company.SSIS.Functions

Public Class ScriptMain

Inherits UserComponent

Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)

Dim PaymentRecord As String = System.Text.Encoding.Unicode.GetString(Row.PaymentMethods.GetBlobData(0, CInt(Row.PaymentMethods.Length)))

Dim PaymentArray() As String

Dim pi As Integer

PaymentArray = Parse.StringParse(PaymentRecord, "\|")

For pi = 0 To PaymentArray.Length - 1

If PaymentArray(pi) <> "" Then

Try

PaymentOutputBuffer.AddRow()

PaymentOutputBuffer.Sequence = pi + 1

PaymentOutputBuffer.ServiceRecordID = Row.ServiceRecordID

PaymentOutputBuffer.PaymentMethod = PaymentArray(pi)

Catch e As Exception

PaymentErrorOutputBuffer.AddRow()

PaymentErrorOutputBuffer.ErrorRecordID = Row.ServiceRecordID

PaymentErrorOutputBuffer.ErrorCode = e.Message

PaymentErrorOutputBuffer.ErrorData.AddBlobData(Encoding.UTF8.GetBytes(PaymentArray(pi)))

End Try

End If

Next

End Sub

End Class

The Company.SSIS.Functions import is a dll I wrote. It has the Parse.StringParse(PaymentRecord, "\|") call. It is simply a regex function. I listed it below.. but basically splits the delimited field into multiple rows. So the goal is that it is called per row, splits the data in the row into an array and stores it as records. If the paymentmethod store fails, the record still gets inserted into the datase with the sequence and service record id. The catch directs creates a second output, that i then store to my error table. I essentially want the catch to still send to my error table, but for the first output not to be created if it fails and enters the catch.

Public Class Parse

Public Shared Function StringParse(ByVal StringValue As String, ByVal ParseValue As String) As String()

If Replace(StringValue, "", Nothing) Is Nothing Then

Return Split(StringValue)

Else

Dim pattern As String = ParseValue & "(?=(?:[^""]*""[^""]*"")*(?![^""]*""))"

Dim r As RegularExpressions.Regex = New RegularExpressions.Regex(pattern)

Return r.Split(StringValue)

End If

End Function

End Class

|||What are some of the reasons why the assignment to PaymentMethod could fail?|||

Payment method is varchar(20) field. The output is defined as String 20. Primary reason of failure is text truncation. On other code it may be bad date/time stamp, non integer value, etc. Typically it is a data error.

I can do a specific check on payment method to make sure its not in error before calling the addrow() so that the output is not called unless it will succeed. But for scenarios I don't think of, or conditions where I need to check 20+ fields this is not as practical. So I was hoping to use a try/catch process to insert the row if its good, otherwise write to the error table.

|||Yep, I hear ya... I just wanted you to think about performing data validation up front, and you have. Good.

Some of the other code experts may have to chime in now. |||Remove the current row with the call to the PipelineBuffer.RemoveRow() method. The script component does not expose the PipelineBuffer.RemoveRow() method directly, but its does expose the PipelineBuffer(s) in PrimeOutput, on which RemoveRow can be called.

Taking your scenario as example, save the underlying pipeline buffers, and call any PipelineBuffer method on them, including RemoveRow.

Imports System

Imports

Microsoft.SqlServer.Dts.Pipeline

Public Class ScriptMain

Inherits

UserComponent

Private

normalBuffer As PipelineBuffer

Private

errorBuffer As PipelineBuffer

Public Overrides Sub

Input0_ProcessInputRow _

(ByVal

Row As Input0Buffer)

Try

With

PaymentOutputBuffer

.AddRow()

.FirstString =

Row.GeneratedStr1

End

With

Catch

ex As Exception

With

PaymentErrorOutputBuffer

.AddRow()

.ErrorMessage =

ex.Message.Substring(0, _

Math.Min(ex.Message.Length,

250))

End

With

normalBuffer.RemoveRow()

' Remove

the row from normal, as normalBuffer

' is the

underlying PipelineBuffer

' for

PaymentOutputBuffer

End Try

End Sub

Public Overrides Sub

PrimeOutput(ByVal Outputs As Integer, _

ByVal

OutputIDs() As Integer,

_

ByVal

Buffers() As

Microsoft.SqlServer.Dts.Pipeline.PipelineBuffer)

' save

underlying PipelineBuffer to allow for calls to

'

PipelineBuffer methods

normalBuffer = Buffers(0)

errorBuffer = Buffers(1)

MyBase.PrimeOutput(Outputs,

OutputIDs, Buffers)

End Sub

End Class

|||Thanks.. .that works and does what I need. I was curious about the Buffers(x) value and if there is another way to set it to the specific outputbuffer. I tried to look at the help on the Pipeline buffer, but was not able to determine it. I want to be able to reference the Buffers(PaymentOutputBuffer) vs. a 0 so that if people add additional buffers, etc it will not break. Is there a way to make this go off the actual buffer name?|||Yes, the buffers can be referenced by name.

The OutputIDs array parameter to PrimeOutput has the integer buffer ids (not the offset) in coordinated order with the Buffers array.

The buffer's name is available via a call to ComponentMetaData.OutputCollection.FindObjectById(<id from OutputIds here>).Name.

See the following BOL reference for the OutputCollection methods: ms-help://MS.VSCC.v80/MS.VSIPCC.v80/MS.SQLSVR.v9.en/dtsref9mref/html/T_Microsoft_SqlServer_Dts_Pipeline_Wrapper_IDTSOutputCollection90_Members.htm

Wednesday, March 28, 2012

Outlook + SQL 2000 SP4 on Windows 2003 2node Active/Passive Cluste

Hi
I have only "heard" that installing Outlook on Windows 2003 cluster running
SQL 2000 might create problems.
Has anyone actually experienced this ? Or am I just hearing rumours.
I would like to install Outlook provided there is no down side to it. What
are the alternatives to Outlook or MAPI all together.
Thanks in advance.Hi
I have not heard of any Outlook/Cluster issue as such but..
it may be the only way of getting Extended MAPI installed on the system
without breaking any licencing agreement or installing exchange server. You
would need to set up exactly the same profile on both side of the cluster.
If you are using a SMTP server (such as excahnge) then you could use XP_SMTP
instead http://www.sqldev.net/xp/xpsmtp.htm
John
"kunalap" wrote:
> Hi
> I have only "heard" that installing Outlook on Windows 2003 cluster running
> SQL 2000 might create problems.
> Has anyone actually experienced this ? Or am I just hearing rumours.
> I would like to install Outlook provided there is no down side to it. What
> are the alternatives to Outlook or MAPI all together.
> Thanks in advance.
>|||"kunalap" <kunalap@.discussions.microsoft.com> wrote in message
news:22DB6194-4E10-4D29-A0D6-4C15B5C5D21D@.microsoft.com...
> Hi
> I have only "heard" that installing Outlook on Windows 2003 cluster
running
> SQL 2000 might create problems.
> Has anyone actually experienced this ? Or am I just hearing rumours.
>
We have done this. The best advice as others have said is make sure the
profile is exactly the same on both servers.
If you're not connecting to an Exchange server,but say just using SMTP to
SEND message from SQL Server, I'd recommend installing a local SMTP instance
on each node and using that to rely the messages.
Have SQL Mail send to the local copy of the SMTP server. That eliminates a
lot of situations where the MAPI client will hang.
> I would like to install Outlook provided there is no down side to it. What
> are the alternatives to Outlook or MAPI all together.
> Thanks in advance.
>

Outlook + SQL 2000 SP4 on Windows 2003 2node Active/Passive Cluste

Hi
I have only "heard" that installing Outlook on Windows 2003 cluster running
SQL 2000 might create problems.
Has anyone actually experienced this ? Or am I just hearing rumours.
I would like to install Outlook provided there is no down side to it. What
are the alternatives to Outlook or MAPI all together.
Thanks in advance.Hi
I have not heard of any Outlook/Cluster issue as such but..
it may be the only way of getting Extended MAPI installed on the system
without breaking any licencing agreement or installing exchange server. You
would need to set up exactly the same profile on both side of the cluster.
If you are using a SMTP server (such as excahnge) then you could use XP_SMTP
instead http://www.sqldev.net/xp/xpsmtp.htm
John
"kunalap" wrote:

> Hi
> I have only "heard" that installing Outlook on Windows 2003 cluster runnin
g
> SQL 2000 might create problems.
> Has anyone actually experienced this ? Or am I just hearing rumours.
> I would like to install Outlook provided there is no down side to it. What
> are the alternatives to Outlook or MAPI all together.
> Thanks in advance.
>|||"kunalap" <kunalap@.discussions.microsoft.com> wrote in message
news:22DB6194-4E10-4D29-A0D6-4C15B5C5D21D@.microsoft.com...
> Hi
> I have only "heard" that installing Outlook on Windows 2003 cluster
running
> SQL 2000 might create problems.
> Has anyone actually experienced this ? Or am I just hearing rumours.
>
We have done this. The best advice as others have said is make sure the
profile is exactly the same on both servers.
If you're not connecting to an Exchange server,but say just using SMTP to
SEND message from SQL Server, I'd recommend installing a local SMTP instance
on each node and using that to rely the messages.
Have SQL Mail send to the local copy of the SMTP server. That eliminates a
lot of situations where the MAPI client will hang.

> I would like to install Outlook provided there is no down side to it. What
> are the alternatives to Outlook or MAPI all together.
> Thanks in advance.
>

Outer Joins

I am trying to create an outer join between two tables in a query that
includes several other tables.

When I double-click on the Join line, it presents three join options:

1) ONLY records from table1 and table2 where join fields are equal
2) ALL values from table1 and ONLY records from table2 where join
fields are equal
3) ALL values from table2 and ONLY records from table1 where join
fields are equal

In my case, I want option 2 - all values from table1, and if there is
no match to table2, I want a blank to appear in the output.

When I select this option, I get the following error:

"Can't have outer joins if there are more than two tables in the
query."

How can I get around this, since there are other tables in my query?

Thanks.

Dennis Hancy
Eaton Corporation
Cleveland, OHThis sounds like a limitation of the GUI application you are using to create
the query. Use Query Analyzer instead. Perhaps you can paste your SQL query
into QA and edit it.

Alternatively, if you are creating a view, Enterprise Manager's view
designer doesn't suffer from this particular restriction but it does have
other limitations so Query Analyzer is probably the best choice if you're
willing and able to write the query yourself.

--
David Portas
SQL Server MVP
--

Monday, March 26, 2012

Outer join query

Hi!
I have a problem with a query:
Two tables:
CREATE TABLE Emp (empno INT, depno INT)
CREATE TABLE Work (empno INT, depno INT, date DATETIME)

I want a list of all employees that belongs to a department (from Emp
table), together with ("union") all employeees WORKING on that department a
spescial day (An employee can have been borrowed from another department
which he does not belong)

Sample data
INSERT INTO Emp (empno, depno) VALUES (1,10)
INSERT INTO Emp (empno, depno) VALUES (2,10)
INSERT INTO Emp (empno, depno) VALUES (3,20)

INSERT INTO Work (empno, depno, date) VALUES (1,10,'2003-10-17')
INSERT INTO Work (empno, depno, date) VALUES (3,10,'2003-10-17')
INSERT INTO Work (empno, depno, date) VALUES (3,10,'2003-10-18')

Note that Employee 3 works on a department to which he does not belong (he
is borrowed to another department)

The following query
SELECT empno, depno, date FROM work WHERE depno = 10 AND date = '2003-10-17'
gives me this result set:

empno depno date
1 10 2003-10-17 00:00:00.000
3 10 2003-10-17 00:00:00.000

But I want employee 2 to appear in the result set as well, because he
belongs to department 10 (eaven thoug he is not working this particular day)

The result set should look like this
empno depno date
1 10 2003-10-01 00:00:00.000
2 10 NULL
3 10 2003-10-01 00:00:00.000

I have tried different approaches, but none of them is good.
Could someone please help me?
Thanks in advance

Regards,
Gunnar Vyenli
EDB-konsulent as
NORWAYSELECT empno, depno,
CASE [date] WHEN '20031017' THEN [date] END AS [date]
FROM Work
WHERE depno = 10

Date is a reserved word and shouldn't be used as a column name (it's a
pretty meaningless name for a column anyway - Date of what?)

--
David Portas
----
Please reply only to the newsgroup
--|||Thanks for your reply, but am afraid this will not do.

I need data from BOTH the tables, not only from Work.
With your query, employee 2 will not be included in the result set, because
he belongs to the Employee table.

In other words: I want a list of all employees who belongs to depno 10,
TOGETHER with all employees which does not belong to depno 10, but work on
depno 10 this particular day.

We are talking about two categories of employees:
1) All the employees who belong to depno 10 (whether they work this day or
not)
2) Those employees who does NOT belong to depno 10, BUT is working at depno
10 this date.

A new suggestion would be apprechiated.

-Gunnar

"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:yrednQ5UUuzGQxKiRVn-vQ@.giganews.com...
> SELECT empno, depno,
> CASE [date] WHEN '20031017' THEN [date] END AS [date]
> FROM Work
> WHERE depno = 10
> Date is a reserved word and shouldn't be used as a column name (it's a
> pretty meaningless name for a column anyway - Date of what?)
> --
> David Portas
> ----
> Please reply only to the newsgroup
> --|||OK. Your DDL was missing any keys. Assuming the PK in Emp is empno and in
Work is (empno, date) and that there is an FK constraint on Work (empno NOT
NULL REFERENCES Emp (empno)):

SELECT COALESCE(E.empno,W.empno) AS empno, 10 AS depno, W.[date]
FROM Emp AS E
LEFT JOIN Work AS W
ON W.empno = E.empno AND W.[date] = '20031017'
WHERE E.depno = 10 OR W.depno = 10

--
David Portas
----
Please reply only to the newsgroup
--|||"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:cNednSW9WZJGaBKiRVn-vQ@.giganews.com...
> OK. Your DDL was missing any keys. Assuming the PK in Emp is empno and in
> Work is (empno, date) and that there is an FK constraint on Work (empno NOT
> NULL REFERENCES Emp (empno)):
> SELECT COALESCE(E.empno,W.empno) AS empno, 10 AS depno, W.[date]
> FROM Emp AS E
> LEFT JOIN Work AS W
> ON W.empno = E.empno AND W.[date] = '20031017'
> WHERE E.depno = 10 OR W.depno = 10

Hi David, minor aside but the call to COALESCE is unnecessary as E.empno
will do. Nice solution.

So as to not be taking up bandwidth with total triviality, here's another take.

SELECT depno, empno, MAX(work_date) AS work_date
FROM (SELECT empno, depno, "date" AS work_date
FROM Work
UNION ALL
SELECT empno, depno, NULL AS work_date
FROM Emp) AS W
WHERE depno = 10 AND
(work_date = '20031017' OR work_date IS NULL)
GROUP BY depno, empno

Regards,
jag

> --
> David Portas
> ----
> Please reply only to the newsgroup
> --

Friday, March 23, 2012

Out params

I heva a sproc that looks something like this:
CREATE PROCEDURE GetData
@.Id INT,
@.Param1 INT OUT,
@.Param2 INT OUT,
@.Param3 INT OUT,
@.Param4 INT OUT,
@.Param5 INT OUT
AS
SET @.Param1 = (SELECT Value1 FROM MyTable WHERE [Id] = @.Id)
SET @.Param2 = (SELECT Value2 FROM MyTable WHERE [Id] = @.Id)
SET @.Param3 = (SELECT Value3 FROM MyTable WHERE [Id] = @.Id)
SET @.Param4 = (SELECT Value4 FROM MyTable WHERE [Id] = @.Id)
SET @.Param5 = (SELECT Value5 FROM MyTable WHERE [Id] = @.Id)
Now this means five selects. How can I rewrite it so it will do only one
select? (I do want to use out params. Not return a recordset.)
--
Mikael EngdahlUse below construct:
SELECT @.parm1 = value1, @.parm2 = value2, ...
FROM MyTable
WHERE...
Note that above will not give an error if the SELECT return more than one row.
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"Mikael Engdahl" <mikael-l@.engdahl.no.spam.com> wrote in message
news:uUyK1POtDHA.1744@.TK2MSFTNGP12.phx.gbl...
> I heva a sproc that looks something like this:
> CREATE PROCEDURE GetData
> @.Id INT,
> @.Param1 INT OUT,
> @.Param2 INT OUT,
> @.Param3 INT OUT,
> @.Param4 INT OUT,
> @.Param5 INT OUT
> AS
> SET @.Param1 = (SELECT Value1 FROM MyTable WHERE [Id] = @.Id)
> SET @.Param2 = (SELECT Value2 FROM MyTable WHERE [Id] = @.Id)
> SET @.Param3 = (SELECT Value3 FROM MyTable WHERE [Id] = @.Id)
> SET @.Param4 = (SELECT Value4 FROM MyTable WHERE [Id] = @.Id)
> SET @.Param5 = (SELECT Value5 FROM MyTable WHERE [Id] = @.Id)
> Now this means five selects. How can I rewrite it so it will do only one
> select? (I do want to use out params. Not return a recordset.)
>
> --
> Mikael Engdahl
>

Out of Order Object ID's

While trying to run an application install that needs to write to
master, it fails b/ c it cant create a new object id. So I followed the
instructions in article 827448 for this error:
Server: Msg 2714, Level 16, State 6, Line 1
There is already an object named 'TableName' in the database.
No matter how many times I run the recommended script and increment "i",
I cant seem to create a new object. My object id's are very sporadic.
Only the first 98 objects are in order. The next number jumps to
1,000,000 and the last object (object#1012) ends in 2,145,442,717.
Questions:
1. What can I do to create a new object?
2. What causes the object id's to be out of order like this? I don't
recall any huge deletes of objects. Certainly not 1,000,000 of them,
unless temp tables are given object ids?
3. Having object ids out of wack like this... does it cause any kind of
performance hit?
Thanks much!
Chris
> While trying to run an application install that needs to write to master,
> it fails b/ c it cant create a new object id. So I followed the
> instructions in article 827448 for this error:
> Server: Msg 2714, Level 16, State 6, Line 1
> There is already an object named 'TableName' in the database.
> No matter how many times I run the recommended script and increment "i", I
> cant seem to create a new object.
The error seems to be that the table already exists. Why are you
incrementing "i"?

> 2. What causes the object id's to be out of order like this? I don't
> recall any huge deletes of objects.
An object_id is assigned arbitrarily by SQL Server. They are not
incremented linearly.
USE TempDB
GO
CREATE TABLE dbo.foo(id INT);
CREATE TABLE dbo.bar(id INT);
SELECT OBJECT_ID('dbo.bar'),OBJECT_ID('dbo.foo');
GO
DROP TABLE dbo.foo,dbo.bar;
GO
On my system, I get:
1870720859, 1854720802
When I run it again, I get:
59238408, 43238351

> Certainly not 1,000,000 of them, unless temp tables are given object ids?
I thought you were "writing to master"? Are you creating permanent tables
in master, or temp tables, or something else?
And yes, temp tables get Object_ids. Run this multiple times:
USE TempDB;
GO
CREATE TABLE #foo(id INT);
SELECT OBJECT_ID('#foo');
DROP TABLE #foo;

> 3. Having object ids out of wack like this... does it cause any kind of
> performance hit?
No, why would it? It's just an arbitrary lookup number. This is like
saying there would be a change in performance if your first name was Wanda
instead of Chris.
Maybe you could explain exactly what you are doing, why you are using a
counter like i and incrementing it, and what the actual failure is.
Aaron
|||Hi Aaron,
I was following the instructions from this article:
http://support.microsoft.com/kb/827448/en-us
I thought object id's were assigned arbitrar numbers. I should have done
a simple test to confirm it (duh) ... but I was taking the word of a
developer. So I second guessed myself.
Aaron Bertrand [SQL Server MVP] wrote:
>
> The error seems to be that the table already exists. Why are you
> incrementing "i"?
>
>
> An object_id is assigned arbitrarily by SQL Server. They are not
> incremented linearly.
> USE TempDB
> GO
> CREATE TABLE dbo.foo(id INT);
> CREATE TABLE dbo.bar(id INT);
> SELECT OBJECT_ID('dbo.bar'),OBJECT_ID('dbo.foo');
> GO
> DROP TABLE dbo.foo,dbo.bar;
> GO
> On my system, I get:
> 1870720859, 1854720802
> When I run it again, I get:
> 59238408, 43238351
>
>
> I thought you were "writing to master"? Are you creating permanent tables
> in master, or temp tables, or something else?
> And yes, temp tables get Object_ids. Run this multiple times:
> USE TempDB;
> GO
> CREATE TABLE #foo(id INT);
> SELECT OBJECT_ID('#foo');
> DROP TABLE #foo;
>
>
> No, why would it? It's just an arbitrary lookup number. This is like
> saying there would be a change in performance if your first name was Wanda
> instead of Chris.
> Maybe you could explain exactly what you are doing, why you are using a
> counter like i and incrementing it, and what the actual failure is.
> Aaron
>
sql

Out of Order Object ID's

While trying to run an application install that needs to write to
master, it fails b/ c it cant create a new object id. So I followed the
instructions in article 827448 for this error:
Server: Msg 2714, Level 16, State 6, Line 1
There is already an object named 'TableName' in the database.
No matter how many times I run the recommended script and increment "i",
I cant seem to create a new object. My object id's are very sporadic.
Only the first 98 objects are in order. The next number jumps to
1,000,000 and the last object (object#1012) ends in 2,145,442,717.
Questions:
1. What can I do to create a new object?
2. What causes the object id's to be out of order like this? I don't
recall any huge deletes of objects. Certainly not 1,000,000 of them,
unless temp tables are given object ids?
3. Having object ids out of wack like this... does it cause any kind of
performance hit?
Thanks much!
Chris> While trying to run an application install that needs to write to master,
> it fails b/ c it cant create a new object id. So I followed the
> instructions in article 827448 for this error:
> Server: Msg 2714, Level 16, State 6, Line 1
> There is already an object named 'TableName' in the database.
> No matter how many times I run the recommended script and increment "i", I
> cant seem to create a new object.
The error seems to be that the table already exists. Why are you
incrementing "i"?

> 2. What causes the object id's to be out of order like this? I don't
> recall any huge deletes of objects.
An object_id is assigned arbitrarily by SQL Server. They are not
incremented linearly.
USE TempDB
GO
CREATE TABLE dbo.foo(id INT);
CREATE TABLE dbo.bar(id INT);
SELECT OBJECT_ID('dbo.bar'),OBJECT_ID('dbo.foo');
GO
DROP TABLE dbo.foo,dbo.bar;
GO
On my system, I get:
1870720859, 1854720802
When I run it again, I get:
59238408, 43238351

> Certainly not 1,000,000 of them, unless temp tables are given object ids?
I thought you were "writing to master"? Are you creating permanent tables
in master, or temp tables, or something else?
And yes, temp tables get Object_ids. Run this multiple times:
USE TempDB;
GO
CREATE TABLE #foo(id INT);
SELECT OBJECT_ID('#foo');
DROP TABLE #foo;

> 3. Having object ids out of wack like this... does it cause any kind of
> performance hit?
No, why would it? It's just an arbitrary lookup number. This is like
saying there would be a change in performance if your first name was Wanda
instead of Chris.
Maybe you could explain exactly what you are doing, why you are using a
counter like i and incrementing it, and what the actual failure is.
Aaron|||Hi Aaron,
I was following the instructions from this article:
http://support.microsoft.com/kb/827448/en-us
I thought object id's were assigned arbitrar numbers. I should have done
a simple test to confirm it (duh) ... but I was taking the word of a
developer. So I second guessed myself.
Aaron Bertrand [SQL Server MVP] wrote:
>
> The error seems to be that the table already exists. Why are you
> incrementing "i"?
>
>
> An object_id is assigned arbitrarily by SQL Server. They are not
> incremented linearly.
> USE TempDB
> GO
> CREATE TABLE dbo.foo(id INT);
> CREATE TABLE dbo.bar(id INT);
> SELECT OBJECT_ID('dbo.bar'),OBJECT_ID('dbo.foo');
> GO
> DROP TABLE dbo.foo,dbo.bar;
> GO
> On my system, I get:
> 1870720859, 1854720802
> When I run it again, I get:
> 59238408, 43238351
>
>
> I thought you were "writing to master"? Are you creating permanent tables
> in master, or temp tables, or something else?
> And yes, temp tables get Object_ids. Run this multiple times:
> USE TempDB;
> GO
> CREATE TABLE #foo(id INT);
> SELECT OBJECT_ID('#foo');
> DROP TABLE #foo;
>
>
> No, why would it? It's just an arbitrary lookup number. This is like
> saying there would be a change in performance if your first name was Wanda
> instead of Chris.
> Maybe you could explain exactly what you are doing, why you are using a
> counter like i and incrementing it, and what the actual failure is.
> Aaron
>

Wednesday, March 21, 2012

Out of Order Object ID's

While trying to run an application install that needs to write to
master, it fails b/ c it cant create a new object id. So I followed the
instructions in article 827448 for this error:
Server: Msg 2714, Level 16, State 6, Line 1
There is already an object named 'TableName' in the database.
No matter how many times I run the recommended script and increment "i",
I cant seem to create a new object. My object id's are very sporadic.
Only the first 98 objects are in order. The next number jumps to
1,000,000 and the last object (object#1012) ends in 2,145,442,717.
Questions:
1. What can I do to create a new object?
2. What causes the object id's to be out of order like this? I don't
recall any huge deletes of objects. Certainly not 1,000,000 of them,
unless temp tables are given object ids?
3. Having object ids out of wack like this... does it cause any kind of
performance hit?
Thanks much!
Chris> While trying to run an application install that needs to write to master,
> it fails b/ c it cant create a new object id. So I followed the
> instructions in article 827448 for this error:
> Server: Msg 2714, Level 16, State 6, Line 1
> There is already an object named 'TableName' in the database.
> No matter how many times I run the recommended script and increment "i", I
> cant seem to create a new object.
The error seems to be that the table already exists. Why are you
incrementing "i"?
> 2. What causes the object id's to be out of order like this? I don't
> recall any huge deletes of objects.
An object_id is assigned arbitrarily by SQL Server. They are not
incremented linearly.
USE TempDB
GO
CREATE TABLE dbo.foo(id INT);
CREATE TABLE dbo.bar(id INT);
SELECT OBJECT_ID('dbo.bar'),OBJECT_ID('dbo.foo');
GO
DROP TABLE dbo.foo,dbo.bar;
GO
On my system, I get:
1870720859, 1854720802
When I run it again, I get:
59238408, 43238351
> Certainly not 1,000,000 of them, unless temp tables are given object ids?
I thought you were "writing to master"? Are you creating permanent tables
in master, or temp tables, or something else?
And yes, temp tables get Object_ids. Run this multiple times:
USE TempDB;
GO
CREATE TABLE #foo(id INT);
SELECT OBJECT_ID('#foo');
DROP TABLE #foo;
> 3. Having object ids out of wack like this... does it cause any kind of
> performance hit?
No, why would it? It's just an arbitrary lookup number. This is like
saying there would be a change in performance if your first name was Wanda
instead of Chris.
Maybe you could explain exactly what you are doing, why you are using a
counter like i and incrementing it, and what the actual failure is.
Aaron|||Hi Aaron,
I was following the instructions from this article:
http://support.microsoft.com/kb/827448/en-us
I thought object id's were assigned arbitrar numbers. I should have done
a simple test to confirm it (duh) ... but I was taking the word of a
developer. So I second guessed myself.
Aaron Bertrand [SQL Server MVP] wrote:
>>While trying to run an application install that needs to write to master,
>>it fails b/ c it cant create a new object id. So I followed the
>>instructions in article 827448 for this error:
>>Server: Msg 2714, Level 16, State 6, Line 1
>>There is already an object named 'TableName' in the database.
>>No matter how many times I run the recommended script and increment "i", I
>>cant seem to create a new object.
>
> The error seems to be that the table already exists. Why are you
> incrementing "i"?
>
>>2. What causes the object id's to be out of order like this? I don't
>>recall any huge deletes of objects.
>
> An object_id is assigned arbitrarily by SQL Server. They are not
> incremented linearly.
> USE TempDB
> GO
> CREATE TABLE dbo.foo(id INT);
> CREATE TABLE dbo.bar(id INT);
> SELECT OBJECT_ID('dbo.bar'),OBJECT_ID('dbo.foo');
> GO
> DROP TABLE dbo.foo,dbo.bar;
> GO
> On my system, I get:
> 1870720859, 1854720802
> When I run it again, I get:
> 59238408, 43238351
>
>>Certainly not 1,000,000 of them, unless temp tables are given object ids?
>
> I thought you were "writing to master"? Are you creating permanent tables
> in master, or temp tables, or something else?
> And yes, temp tables get Object_ids. Run this multiple times:
> USE TempDB;
> GO
> CREATE TABLE #foo(id INT);
> SELECT OBJECT_ID('#foo');
> DROP TABLE #foo;
>
>>3. Having object ids out of wack like this... does it cause any kind of
>>performance hit?
>
> No, why would it? It's just an arbitrary lookup number. This is like
> saying there would be a change in performance if your first name was Wanda
> instead of Chris.
> Maybe you could explain exactly what you are doing, why you are using a
> counter like i and incrementing it, and what the actual failure is.
> Aaron
>

Tuesday, March 20, 2012

Otain error details from a DTS package through T-SQL. Was(xp_sendmail on script

SQL Server 2000

Good day all,

I've been asked to create a DTS package that will execute 2 other DTS packages (yeah, I know... personally I want to write a sp for it *shrug*) and send an e-mail out reporting a failure and failure details.

So I have a couple of questions for you;

How do I pick up the error number (and description?) from a failed DTS and pass it to my sendmail task?
Is it possible to send anything other than plain text e-mails?
Can I change the e-mail priority to "high"?

I appreciate any help you can offer me :)USE master
GO

IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'S' AND name = 'sp_dtsFailureEmail') BEGIN
DROP PROCEDURE sp_dtsFailureEmail
END
GO

CREATE PROCEDURE sp_dtsFailureEmail
@.dtsName varchar(64)
, @.errorNumber int = 0
AS

IF @.errorNumber <> 0 BEGIN
DECLARE @.message varchar(2000)
, @.subject varchar(255)
, @.errorDesc nvarchar(255)

SET @.errorDesc = (SELECT description FROM sysmessages WHERE error = @.errorNumber)
SET @.subject = '***DTS FAILURE*** ' + @.dtsname + ' ***DTS FAILURE***'
SET @.message = 'DTS Package:' + Char(9) + Char(9) + @.dtsName
+ Char(13) + 'Failure Date:' + Char(9) + Char(9) + Convert(varchar, GetDate(), 0)
+ Char(13) + 'Error Number:' + Char(9) + Char(9) + Convert(varchar, @.errorNumber)
+ Char(13) + 'Error Description:' + Char(9) + @.errorDesc

PRINT ''
PRINT @.subject
PRINT ''
PRINT @.message
PRINT ''

EXEC xp_sendmail
@.recipients = '<enter your e-mail address>'
, @.subject = @.subject
, @.message = @.message
END
ELSE BEGIN
PRINT 'No Error'
END
GO

SELECT 1/0

EXEC sp_dtsFailureEmail '<enter dtsName>', @.@.Error

DROP PROCEDURE sp_dtsFailureEmail

I'm getting close, but I still don't know how to pass the error number from a DTS to... anywhere!!|||EXEC xp_cmdshell 'DTSRun /S "SQL-XXXX-XXXXX" /N "<dtsname>" /G "{5A14F80F-8EE2-477D-BE95-DC90A343D2A3}" /W "0" /E '
SELECT @.@.Error

Returns no error number when the DTS fails... So this suggests that this cannot be done!
Any ideas?|||As you know I know stuff all about DTS but you are not getting much help here.

1) Should you change the title of the thread? The problem does not really have anything to do with xp_sendmail.
2) Have you tried:

Declare @.error_return AS INT
EXEC @.error_return = xp_cmdshell 'DTSRun /S "SQL-XXXX-XXXXX" /N "<dtsname>" /G "{5A14F80F-8EE2-477D-BE95-DC90A343D2A3}" /W "0" /E '
SELECT @.error_return ??
3) Have you considered setting up a global variable, trapping the error in the DTS script and setting the global. Then test the global when the DTS script has finished.

HTH|||1) Wilco... my q2&3 were sp_sendmail though..

2) I'm just working on that! It returns a bit value declaring whether there was an error or not.

3) Never used global variables in DTS before - will look up if I run into a dead end with point 2.

Here's my current working code.

USE master
GO

IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'S' AND name = 'sp_dtsFailureEmail') BEGIN
DROP PROCEDURE sp_dtsFailureEmail
END
GO

CREATE PROCEDURE sp_dtsFailureEmail
@.dtsName varchar(64)
AS

DECLARE @.message varchar(8000)
, @.subject varchar(255)
, @.errorDesc nvarchar(255)

-- SET @.errorDesc = (SELECT description FROM sysmessages WHERE error = @.errorNumber)
SET @.subject = '***DTS FAILURE*** ' + @.dtsname + ' ***DTS FAILURE***'
SET @.message = 'DTS Package:' + Char(9) + Char(9) + @.dtsName
+ Char(13) + 'Failure Date:' + Char(9) + Char(9) + Convert(varchar, GetDate(), 0)
-- + Char(13) + 'Error Number:' + Char(9) + Char(9) + Convert(varchar, @.errorNumber)
-- + Char(13) + 'Error Description:' + Char(9) + @.errorDesc

PRINT ''
PRINT @.subject
PRINT ''
PRINT @.message
PRINT ''

-- EXEC xp_sendmail
-- @.recipients = '<enter your email>'
-- , @.subject = @.subject
-- , @.message = @.message
-- END
GO

DECLARE @.err bit
DECLARE @.dts varchar(64)
DECLARE @.cmd varchar(1024)

SET @.dts = 'test'
SET @.cmd = 'DTSRun /S "SQL-LIVE-IT038" /N "' + @.dts + '" /W "0" /E'

EXEC @.err = xp_cmdshell @.cmd
IF @.err <> 0 BEGIN
EXEC sp_dtsFailureEmail @.dts
END

DROP PROCEDURE sp_dtsFailureEmail

Returns:

DTSRun: Loading...
DTSRun: Executing...
DTSRun OnStart: DTSStep_DTSExecuteSQLTask_1
DTSRun OnError: DTSStep_DTSExecuteSQLTask_1, Error = -2147217900 (80040E14)
Error string: Divide by zero error encountered.
Error source: Microsoft OLE DB Provider for SQL Server
Help file:
Help context: 0

Error Detail Records:

Error: -2147217900 (80040E14); Provider Error: 8134 (1FC6)
Error string: Divide by zero error encountered.
Error source: Microsoft OLE DB Provider for SQL Server
Help file:
Help context: 0

DTSRun OnFinish: DTSStep_DTSExecuteSQLTask_1
DTSRun: Package execution complete.
NULL

***DTS FAILURE*** test ***DTS FAILURE***

DTS Package: test
Failure Date: Sep 5 2007 12:16PM

This raises another question: Is it possible to retrieve the output information from xp_cmdshell?|||This raises another question: Is it possible to retrieve the output information from xp_cmdshell?You mean stuff printed to the window? No.

How come? Are you hoping to get the details?

As said I don't know DTS but can you get the details within the package? If so then you can write all this to a table and check that.|||You mean stuff printed to the window?

Yep.

How come? Are you hoping to get the details?

Yep.

Basically the aim is to e-mail a group of users with the error details of a DTS package. But I'm startign to think it's more trouble than it's worth ;)|||GeorgeV on DTS: Basically the aim is to e-mail a group of users with the error details of a DTS package. But I'm startign to think it's more trouble than it's worth ;)

Strong candidate for my new sig ;)

That, for me, is DTS through and through.|||Yeeeeappp...
I'd love to rewrite the whole script in T-SQL; but can't...

I don't know how to do absolutely everything the DTS does
It's classed as a "major change" and I really cba going through all that just to do it.

A colleague of mine wrote a couple of hefty SSIS packages a while back which took a few CSV's from a 3rd party product and transformed them into our databases... All was fine until the column order changed on the CSV file. So even SSIS does the simplest of jobs badly.|||A colleague of mine wrote a couple of hefty SSIS packages a while back which took a few CSV's from a 3rd party product and transformed them into our databases... All was fine until the column order changed on the CSV file. So even SSIS does the simplest of jobs badly.To be fair unless you write bullet proof dynamic sql or have some sort of config file T-SQL will fair no better. I imagine Pat would start muttering something about "contracts" upon reading this. You change the contract between two systems and you can't really expect things to run smoothly.|||Actually, to resolve this an interim DTS package was created which produces a "clean" file. DTS packages remember the mapping.

The 3rd party product cost a total of $99 - we got what we paid for :p

Friday, March 9, 2012

OSQL usage

Hi All,
Is it possible to create a database (databse.mdf file) at a specified
location using OSQL ?
Thanks in advance for any help,
Piyush
hi Piyush,
"Piyush" <anonymus@.hotmail.com> ha scritto nel messaggio
news:%23XlPdRfqEHA.3728@.TK2MSFTNGP09.phx.gbl
> Hi All,
> Is it possible to create a database (databse.mdf file) at a specified
> location using OSQL ?
> Thanks in advance for any help,
> Piyush
a good article about oSql can be found at
http://support.microsoft.com/default...EN-US;q325003, and, of
course, it is possible to define a specific database's files location, using
the standard CREATE DATABASE syntax
(http://msdn.microsoft.com/library/de...-us/tsqlref/ts
_create_1up1.asp)
for your convenience, you can download the SQL Server Books On Line at
http://www.microsoft.com/sql/techinf...000/books.asp, the on line
help for SQL Server, including all Transact-SQL reference
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
DbaMgr2k ver 0.9.1 - DbaMgr ver 0.55.1
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply
|||Thanks Andrea,
The create Database scheme works fine for me.
regards,
Piyush
But is this possible using OSQL.
"Andrea Montanari" <andrea.sqlDMO@.virgilio.it> wrote in message
news:2scla2F1ijfkfU1@.uni-berlin.de...
> hi Piyush,
> "Piyush" <anonymus@.hotmail.com> ha scritto nel messaggio
> news:%23XlPdRfqEHA.3728@.TK2MSFTNGP09.phx.gbl
> a good article about oSql can be found at
> http://support.microsoft.com/default...EN-US;q325003, and, of
> course, it is possible to define a specific database's files location,
using
> the standard CREATE DATABASE syntax
>
(http://msdn.microsoft.com/library/de...-us/tsqlref/ts
> _create_1up1.asp)
> for your convenience, you can download the SQL Server Books On Line at
> http://www.microsoft.com/sql/techinf...000/books.asp, the on
line
> help for SQL Server, including all Transact-SQL reference
> --
> Andrea Montanari (Microsoft MVP - SQL Server)
> http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
> DbaMgr2k ver 0.9.1 - DbaMgr ver 0.55.1
> (my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
> interface)
> -- remove DMO to reply
>

Wednesday, March 7, 2012

OSQL output file contains extra blank lines

I have a process where I am trying to run "sp_helptext" in OSQL and piping
the output to a file so that I could basically generate the "Create
Procedure" statement for a particular Stored Proc. When I run this - I am
getting extra blank lines in the output file.
For example, I run the following OSQL command to generate the pubs.ByRoyalty
stored procedure:
osql -n -h-1 -w180 -SServerName-dpubs -Usa -Psapass -Q"exec sp_Helptext
byroyalty" >ByRoyalty.sql
The contents of ByRoyaly.sql is below...(Note all the annoying blank lines).
Is there any osql switch that could eliminate these blank lines? I've tried
adjusting the -w switch and it has no affect.
Thanks!
CREATE PROCEDURE byroyalty @.percentage int
AS
select au_id from titleauthor
where titleauthor.royaltyper = @.percentageIf you can work with other tools like the query analyzer instead you can get
the desired output using the following script:
USE pubs
CREATE TABLE #ByRoyalty (output varchar(8000))
INSERT #ByRoyalty
EXEC sp_helptext byroyalty
SELECT * FROM #ByRoyalty
The trick now is to find a way to send the output to a file
Hope it helps
"TJTODD" wrote:
> I have a process where I am trying to run "sp_helptext" in OSQL and piping
> the output to a file so that I could basically generate the "Create
> Procedure" statement for a particular Stored Proc. When I run this - I am
> getting extra blank lines in the output file.
> For example, I run the following OSQL command to generate the pubs.ByRoyalty
> stored procedure:
> osql -n -h-1 -w180 -SServerName-dpubs -Usa -Psapass -Q"exec sp_Helptext
> byroyalty" >ByRoyalty.sql
> The contents of ByRoyaly.sql is below...(Note all the annoying blank lines).
> Is there any osql switch that could eliminate these blank lines? I've tried
> adjusting the -w switch and it has no affect.
> Thanks!
>
> CREATE PROCEDURE byroyalty @.percentage int
>
> AS
>
> select au_id from titleauthor
>
> where titleauthor.royaltyper = @.percentage
>
>

osql -o

I would like to create a dynamic output file with the following code:
Declare @.cmd varchar(1000)
Declare @.filepath varchar(1000)
Set @.filepath = '\\server\path\filename+date.csv >>>> I would like the
mm/dd/yy appended to the filename then .csv extension
Set @.cmd = 'Osql -E -S MyservA -d msdb -Q "sp_databases" /o "@.Filepath" -w
2000' >>>> here is where I would like the new filename to be used.
Exec master..xp_cmdshell @.cmd
Is there also anyway to log this to a file to track execution ?
Thanks...Hi,
you might be interested in that:
http://www.databasejournal.com/feat...cle.php/3386661
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Hoosbruin" <Hoosbruin@.Kconline.com> schrieb im Newsbeitrag
news:BNGdnQ_yUIxBcuvfRVn-1Q@.kconline.com...
>I would like to create a dynamic output file with the following code:
>
> Declare @.cmd varchar(1000)
> Declare @.filepath varchar(1000)
> Set @.filepath = '\\server\path\filename+date.csv >>>> I would like the
> mm/dd/yy appended to the filename then .csv extension
> Set @.cmd = 'Osql -E -S MyservA -d msdb -Q "sp_databases" /o "@.Filepath" -w
> 2000' >>>> here is where I would like the new filename to be used.
> Exec master..xp_cmdshell @.cmd
>
> Is there also anyway to log this to a file to track execution ?
>
> Thanks...
>
>
>

osql formatting

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.Use the -s to set a column separator. The columns come out fixed width unless you give a separator.

-PatP|||Use the -s to set a column separator. The columns come out fixed width unless you give a separator.

-PatP

Thanks!
It helps a little. Once I use -s option leading spaces disappeared.
But I still have no idea how to remove white spaces at the end of each line.
It happens when the fields I spool contain numbers with different lenght.
(in expample: 9, 100, 21, etc.)
When I use ltrim/rtrim(..) functions (and str(..) function too) the white spaces are moved from the fields to the end of the line.

I think it may be a problem with the length of each line.
Does each line of a spool file (created by OSQL) has to have the same length? For me it makes no sense...|||I would trim the lines on the client if that was the case. The whitespace trimming is really a presentation issue, and should be done on the client anyway.

-PatP|||I would trim the lines on the client if that was the case. The whitespace trimming is really a presentation issue, and should be done on the client anyway.

-PatP

You are 100% right.
I would do it on the client if only I could do it...
Unfortunately the data format on the client is strictly fixed and I cannot change it.
The second problem is that the file is big and SED (stream editor) is working so so with such a big file.
As a new MS SQL 2k user I have to say that this kind of problem was unknown for me when I started working with Oracle DB. Simple spool could do anything...|||First of all, I'd like some more information on what you are doing that is causing such problems.

Can you post the DDL (the SQL statements that create the tables), and the DML (the SQL statements that return the data) that are causing you these problems? When I build test cases trying to cause the kind of problems you are describing, I can't do it unless I deliberately set things up to cause the problem.

Next order of business, you could use any of several client tools that don't even get "warmed up" very well for 300 Mb of data. Some of these tools, like Perl (http://www.perl.org/) are both free and multi-platform. Others range widely in price, functionality, and platform.

I'm pretty sure that OSQL can do what you want. I just need to see what you are doing in order to understand what problems you are having. Even if OSQL can't do it, there are plenty of other tools that can, but until I understand what the problem is, I can't help you much.

-PatP|||First of all, I'd like some more information on what you are doing that is causing such problems.

Can you post the DDL (the SQL statements that create the tables), and the DML (the SQL statements that return the data) that are causing you these problems? When I build test cases trying to cause the kind of problems you are describing, I can't do it unless I deliberately set things up to cause the problem.

Next order of business, you could use any of several client tools that don't even get "warmed up" very well for 300 Mb of data. Some of these tools, like Perl (http://www.perl.org/) are both free and multi-platform. Others range widely in price, functionality, and platform.

I'm pretty sure that OSQL can do what you want. I just need to see what you are doing in order to understand what problems you are having. Even if OSQL can't do it, there are plenty of other tools that can, but until I understand what the problem is, I can't help you much.

-PatP

I've been doing some tests and I've noticed that OSQL seems to be a "fixed row length" spooler.
But of course I can be wrong.

Now I'm not able to login to the MS SQL 2k db
but I far as I remember the columns look like these:

* msisdn - number(11) -> NULL values are allowed and many NULL values exist
* bserv - varchar2(10)
* id - number(13) -> NULL values are not allowed

And this is the query (looking rather simple...):

query1.sql:

use [SQL_REPLICA]
GO
SET NOCOUNT ON
select
rtrim(case when msisdn is NULL then '' else str(msisdn, 11) end + ',' +
bserv + ',' +
str(id + 1200000000000, 13))
from msisdn_codes
GO

and OSQL command line:

osql -E -h-1 -s "" -n -i query1.sql -o msisdn.dat

Switch -s "" seems to be not obligatory but once I added this swich, leading spaces (at the begining of each line) from the spool file disappered.
To remove white spaces I've been trying to use SED:

sed "s/ //g" msisdn.dat msidn_sr.dat
move msisdn_sr.dat msisdn.dat

or PERL (thanks for your hint!):

use Tie::File;
tie @.array, 'Tie::File', 'msisdn.dat';
for (@.array)
{
s/ //g;
}
untie @.array;

But it takes to much time.
It took 40 minutes to remove white spaces from the file of 100 MB (PERL).
In fact I did the tests on my laptop (only 1,7GHz and 512 MB RAM), but the server is not much faster (Intel Xeon 3GHz, 2 GB RAM).

Thanks for your help and patience...|||If all you need is a text file of a specific most elaborate format, then OSQL is not the utility you need. All you need to do is create your sophistication using a view, and then BCP that view OUT using "-c" switch.|||If all you need is a text file of a specific most elaborate format, then OSQL is not the utility you need. All you need to do is create your sophistication using a view, and then BCP that view OUT using "-c" switch.

You might be right.
The simpliest solution - the best solution.
I'll try to do it the way you suggest.
Thanks for help.|||If all you need is a text file of a specific most elaborate format, then OSQL is not the utility you need. All you need to do is create your sophistication using a view, and then BCP that view OUT using "-c" switch.

It works perfectly!
That is what I need.
Thanks a lot!

Saturday, February 25, 2012

osql - creating a DB - permission problem.

Hi;
I am trying to create a database from the command line using osql and a .sql
file. If I create the database first in the enterprise manager and then run
it - it works fine. But if the database does not exist I get:
C:\src\RePortal\SqlScripts>"\Program Files\Microsoft SQL
Server\90\Tools\Binn\OS
QL.EXE" -S ARIEL -d WindwardPortal -E -i
\src\RePortal\SqlScripts\SqlServer.sql
Login failed for user 'THIELEN\dave'.
[SQL Native Client]Shared Memory Provider: The system cannot open the file.
[SQL Native Client]Communication link failure
Cannot open database requested in login 'WindwardPortal'. Login fails.
The file SqlServer.sql starts with:
CREATE DATABASE [WindwardPortal]
GO
use [WindwardPortal]
GO
/****** Object: Table [dbo].[Datasource] Script Date: 11/16/2006 2:06:26
PM ******/
CREATE TABLE [dbo].[Datasource] (
[datasourceId] [int] IDENTITY (1, 1) NOT NULL ,
any ideas?
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
Cubicle Wars - http://www.windwardreports.com/film.htm
Since the database has not yet been created. OSQL cannot set the database
context to that database with the "-d WindwardPortal" specification. You
can remove "-d WindwardPortal" since you have a USE following the CREATE
DATABASE.
Hope this helps.
Dan Guzman
SQL Server MVP
"David Thielen" <thielen@.nospam.nospam> wrote in message
news:1D648FD7-2565-4DFD-B3AF-1867E6B3445C@.microsoft.com...
> Hi;
> I am trying to create a database from the command line using osql and a
> .sql
> file. If I create the database first in the enterprise manager and then
> run
> it - it works fine. But if the database does not exist I get:
> C:\src\RePortal\SqlScripts>"\Program Files\Microsoft SQL
> Server\90\Tools\Binn\OS
> QL.EXE" -S ARIEL -d WindwardPortal -E -i
> \src\RePortal\SqlScripts\SqlServer.sql
> Login failed for user 'THIELEN\dave'.
> [SQL Native Client]Shared Memory Provider: The system cannot open the
> file.
> [SQL Native Client]Communication link failure
> Cannot open database requested in login 'WindwardPortal'. Login fails.
> The file SqlServer.sql starts with:
> CREATE DATABASE [WindwardPortal]
> GO
> use [WindwardPortal]
> GO
> /****** Object: Table [dbo].[Datasource] Script Date: 11/16/2006
> 2:06:26
> PM ******/
> CREATE TABLE [dbo].[Datasource] (
> [datasourceId] [int] IDENTITY (1, 1) NOT NULL ,
> any ideas?
> --
> thanks - dave
> david_at_windward_dot_net
> http://www.windwardreports.com
> Cubicle Wars - http://www.windwardreports.com/film.htm
>
|||Hello,
Looks like the path for SQLServer.SQL is wrong. As a first step try login
using OSQL with out giving the database name and script name.
OSQL -S Servername -E
Thanks
Hari
"David Thielen" <thielen@.nospam.nospam> wrote in message
news:1D648FD7-2565-4DFD-B3AF-1867E6B3445C@.microsoft.com...
> Hi;
> I am trying to create a database from the command line using osql and a
> .sql
> file. If I create the database first in the enterprise manager and then
> run
> it - it works fine. But if the database does not exist I get:
> C:\src\RePortal\SqlScripts>"\Program Files\Microsoft SQL
> Server\90\Tools\Binn\OS
> QL.EXE" -S ARIEL -d WindwardPortal -E -i
> \src\RePortal\SqlScripts\SqlServer.sql
> Login failed for user 'THIELEN\dave'.
> [SQL Native Client]Shared Memory Provider: The system cannot open the
> file.
> [SQL Native Client]Communication link failure
> Cannot open database requested in login 'WindwardPortal'. Login fails.
> The file SqlServer.sql starts with:
> CREATE DATABASE [WindwardPortal]
> GO
> use [WindwardPortal]
> GO
> /****** Object: Table [dbo].[Datasource] Script Date: 11/16/2006
> 2:06:26
> PM ******/
> CREATE TABLE [dbo].[Datasource] (
> [datasourceId] [int] IDENTITY (1, 1) NOT NULL ,
> any ideas?
> --
> thanks - dave
> david_at_windward_dot_net
> http://www.windwardreports.com
> Cubicle Wars - http://www.windwardreports.com/film.htm
>

osql - creating a DB - permission problem.

Hi;
I am trying to create a database from the command line using osql and a .sql
file. If I create the database first in the enterprise manager and then run
it - it works fine. But if the database does not exist I get:
C:\src\RePortal\SqlScripts>"\Program Files\Microsoft SQL
Server\90\Tools\Binn\OS
QL.EXE" -S ARIEL -d WindwardPortal -E -i
\src\RePortal\SqlScripts\SqlServer.sql
Login failed for user 'THIELEN\dave'.
[SQL Native Client]Shared Memory Provider: The system cannot open the fi
le.
[SQL Native Client]Communication link failure
Cannot open database requested in login 'WindwardPortal'. Login fails.
The file SqlServer.sql starts with:
CREATE DATABASE [WindwardPortal]
GO
use [WindwardPortal]
GO
/****** Object: Table [dbo].[Datasource] Script Date: 11/16/2006
2:06:26
PM ******/
CREATE TABLE [dbo].[Datasource] (
[datasourceId] [int] IDENTITY (1, 1) NOT NULL ,
any ideas?
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
Cubicle Wars - http://www.windwardreports.com/film.htmSince the database has not yet been created. OSQL cannot set the database
context to that database with the "-d WindwardPortal" specification. You
can remove "-d WindwardPortal" since you have a USE following the CREATE
DATABASE.
Hope this helps.
Dan Guzman
SQL Server MVP
"David Thielen" <thielen@.nospam.nospam> wrote in message
news:1D648FD7-2565-4DFD-B3AF-1867E6B3445C@.microsoft.com...
> Hi;
> I am trying to create a database from the command line using osql and a
> .sql
> file. If I create the database first in the enterprise manager and then
> run
> it - it works fine. But if the database does not exist I get:
> C:\src\RePortal\SqlScripts>"\Program Files\Microsoft SQL
> Server\90\Tools\Binn\OS
> QL.EXE" -S ARIEL -d WindwardPortal -E -i
> \src\RePortal\SqlScripts\SqlServer.sql
> Login failed for user 'THIELEN\dave'.
> [SQL Native Client]Shared Memory Provider: The system cannot open the
> file.
> [SQL Native Client]Communication link failure
> Cannot open database requested in login 'WindwardPortal'. Login fails.
> The file SqlServer.sql starts with:
> CREATE DATABASE [WindwardPortal]
> GO
> use [WindwardPortal]
> GO
> /****** Object: Table [dbo].[Datasource] Script Date: 11/16/20
06
> 2:06:26
> PM ******/
> CREATE TABLE [dbo].[Datasource] (
> [datasourceId] [int] IDENTITY (1, 1) NOT NULL ,
> any ideas?
> --
> thanks - dave
> david_at_windward_dot_net
> http://www.windwardreports.com
> Cubicle Wars - http://www.windwardreports.com/film.htm
>|||Hello,
Looks like the path for SQLServer.SQL is wrong. As a first step try login
using OSQL with out giving the database name and script name.
OSQL -S Servername -E
Thanks
Hari
"David Thielen" <thielen@.nospam.nospam> wrote in message
news:1D648FD7-2565-4DFD-B3AF-1867E6B3445C@.microsoft.com...
> Hi;
> I am trying to create a database from the command line using osql and a
> .sql
> file. If I create the database first in the enterprise manager and then
> run
> it - it works fine. But if the database does not exist I get:
> C:\src\RePortal\SqlScripts>"\Program Files\Microsoft SQL
> Server\90\Tools\Binn\OS
> QL.EXE" -S ARIEL -d WindwardPortal -E -i
> \src\RePortal\SqlScripts\SqlServer.sql
> Login failed for user 'THIELEN\dave'.
> [SQL Native Client]Shared Memory Provider: The system cannot open the
> file.
> [SQL Native Client]Communication link failure
> Cannot open database requested in login 'WindwardPortal'. Login fails.
> The file SqlServer.sql starts with:
> CREATE DATABASE [WindwardPortal]
> GO
> use [WindwardPortal]
> GO
> /****** Object: Table [dbo].[Datasource] Script Date: 11/16/20
06
> 2:06:26
> PM ******/
> CREATE TABLE [dbo].[Datasource] (
> [datasourceId] [int] IDENTITY (1, 1) NOT NULL ,
> any ideas?
> --
> thanks - dave
> david_at_windward_dot_net
> http://www.windwardreports.com
> Cubicle Wars - http://www.windwardreports.com/film.htm
>

osql - creating a DB - permission problem.

Hi;
I am trying to create a database from the command line using osql and a .sql
file. If I create the database first in the enterprise manager and then run
it - it works fine. But if the database does not exist I get:
C:\src\RePortal\SqlScripts>"\Program Files\Microsoft SQL
Server\90\Tools\Binn\OS
QL.EXE" -S ARIEL -d WindwardPortal -E -i
\src\RePortal\SqlScripts\SqlServer.sql
Login failed for user 'THIELEN\dave'.
[SQL Native Client]Shared Memory Provider: The system cannot open the file.
[SQL Native Client]Communication link failure
Cannot open database requested in login 'WindwardPortal'. Login fails.
The file SqlServer.sql starts with:
CREATE DATABASE [WindwardPortal]
GO
use [WindwardPortal]
GO
/****** Object: Table [dbo].[Datasource] Script Date: 11/16/2006 2:06:26
PM ******/
CREATE TABLE [dbo].[Datasource] (
[datasourceId] [int] IDENTITY (1, 1) NOT NULL ,
any ideas?
--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
Cubicle Wars - http://www.windwardreports.com/film.htmSince the database has not yet been created. OSQL cannot set the database
context to that database with the "-d WindwardPortal" specification. You
can remove "-d WindwardPortal" since you have a USE following the CREATE
DATABASE.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"David Thielen" <thielen@.nospam.nospam> wrote in message
news:1D648FD7-2565-4DFD-B3AF-1867E6B3445C@.microsoft.com...
> Hi;
> I am trying to create a database from the command line using osql and a
> .sql
> file. If I create the database first in the enterprise manager and then
> run
> it - it works fine. But if the database does not exist I get:
> C:\src\RePortal\SqlScripts>"\Program Files\Microsoft SQL
> Server\90\Tools\Binn\OS
> QL.EXE" -S ARIEL -d WindwardPortal -E -i
> \src\RePortal\SqlScripts\SqlServer.sql
> Login failed for user 'THIELEN\dave'.
> [SQL Native Client]Shared Memory Provider: The system cannot open the
> file.
> [SQL Native Client]Communication link failure
> Cannot open database requested in login 'WindwardPortal'. Login fails.
> The file SqlServer.sql starts with:
> CREATE DATABASE [WindwardPortal]
> GO
> use [WindwardPortal]
> GO
> /****** Object: Table [dbo].[Datasource] Script Date: 11/16/2006
> 2:06:26
> PM ******/
> CREATE TABLE [dbo].[Datasource] (
> [datasourceId] [int] IDENTITY (1, 1) NOT NULL ,
> any ideas?
> --
> thanks - dave
> david_at_windward_dot_net
> http://www.windwardreports.com
> Cubicle Wars - http://www.windwardreports.com/film.htm
>|||Hello,
Looks like the path for SQLServer.SQL is wrong. As a first step try login
using OSQL with out giving the database name and script name.
OSQL -S Servername -E
Thanks
Hari
"David Thielen" <thielen@.nospam.nospam> wrote in message
news:1D648FD7-2565-4DFD-B3AF-1867E6B3445C@.microsoft.com...
> Hi;
> I am trying to create a database from the command line using osql and a
> .sql
> file. If I create the database first in the enterprise manager and then
> run
> it - it works fine. But if the database does not exist I get:
> C:\src\RePortal\SqlScripts>"\Program Files\Microsoft SQL
> Server\90\Tools\Binn\OS
> QL.EXE" -S ARIEL -d WindwardPortal -E -i
> \src\RePortal\SqlScripts\SqlServer.sql
> Login failed for user 'THIELEN\dave'.
> [SQL Native Client]Shared Memory Provider: The system cannot open the
> file.
> [SQL Native Client]Communication link failure
> Cannot open database requested in login 'WindwardPortal'. Login fails.
> The file SqlServer.sql starts with:
> CREATE DATABASE [WindwardPortal]
> GO
> use [WindwardPortal]
> GO
> /****** Object: Table [dbo].[Datasource] Script Date: 11/16/2006
> 2:06:26
> PM ******/
> CREATE TABLE [dbo].[Datasource] (
> [datasourceId] [int] IDENTITY (1, 1) NOT NULL ,
> any ideas?
> --
> thanks - dave
> david_at_windward_dot_net
> http://www.windwardreports.com
> Cubicle Wars - http://www.windwardreports.com/film.htm
>

Monday, February 20, 2012

OS error 53 for SQL servers VPN replication?

I've got this error message when trying to create a subscriber from a
publisher through VPN in a non-trusted domain, I am using SQL server
authentication:
The schema script '\\MERCURY\G$\Program Files\Microsoft SQL
Server\MSSQL$MERCURY\ReplData\unc\MERCUR
Y$MERCURY_Northwind_NorthwindMercury
Pub1\20040221225704\snapshot.pre' could not be propagated to the subscriber.
(Source: Merge Replication Provider (Agent); Error number: -2147201001)
----
--
The process could not read file '\\MERCURY\G$\Program Files\Microsoft SQL
Server\MSSQL$MERCURY\ReplData\unc\MERCUR
Y$MERCURY_Northwind_NorthwindMercury
Pub1\20040221225704\snapshot.pre' due to OS error 53.
(Source: ECSWEB (Agent); Error number: 0)
----
--
The network path was not found.
(Source: (OS); Error number: 53)
What is OS error 53 and how can it be fixed?This error is generally caused by the fact that the SQL Server Agent
startup account on either the publisher or subscriber is not a local
administrator on one or both of the machines.
The default location for the snapshot folder is an administrative share and
as such the SQL Server Agent acount must be a local adminsitrator to access
it. From the error I am going to presume that you are creating a pull
subscription so the SQL Server Agent startup account at the subscriber must
be a local admin on the publisher. You can verify if this is the problem by
logging on to the subscriber using the SQL Server Agent startup account and
try to map a drive to the snap shot folder on the publisher:
\\MERCURY\G$\
If that fails with the same error then you have your reason for the failure.
Rand
This posting is provided "as is" with no warranties and confers no rights.|||Thanks Rand,
Yes that's right the two SQL servers are in different
non-trusted domains connected through VPN. The Distributor and Publisher SQL
Server is in the NARC domain and Agent login account as NARC\Administrator.
And the subscriber is in the HOT domain and Agent Login account is
HOT\Administrator. No trusted can be established between them. What must I
do to achieved successful pull subscription? How do I allow permissions in
the NARC domain for HOT\Administrator if there's no trusted' What about
independent SQL server logins to access shares in NARC domain(How do I set
it up if possible)?
Thanks
"Rand Boyd [MSFT]" <rboyd@.onlinemicrosoft.com> wrote in message
news:fjJVvoV$DHA.3712@.cpmsftngxa06.phx.gbl...
> This error is generally caused by the fact that the SQL Server Agent
> startup account on either the publisher or subscriber is not a local
> administrator on one or both of the machines.
> The default location for the snapshot folder is an administrative share
and
> as such the SQL Server Agent acount must be a local adminsitrator to
access
> it. From the error I am going to presume that you are creating a pull
> subscription so the SQL Server Agent startup account at the subscriber
must
> be a local admin on the publisher. You can verify if this is the problem
by
> logging on to the subscriber using the SQL Server Agent startup account
and
> try to map a drive to the snap shot folder on the publisher:
> \\MERCURY\G$\
> If that fails with the same error then you have your reason for the
failure.
> Rand
> This posting is provided "as is" with no warranties and confers no rights.
>|||Joe,
I haven't got Rand's post available here, but I would advise to either use
SQL security or use pass-through authentication. Both are described in the
link in my earlier post.
Regards,
Paul Ibison
"Joe Mine" <huytuanattpgdotcomdotau> wrote in message
news:u9ThB04$DHA.2216@.TK2MSFTNGP10.phx.gbl...
> Thanks Rand,
> Yes that's right the two SQL servers are in different
> non-trusted domains connected through VPN. The Distributor and Publisher
SQL
> Server is in the NARC domain and Agent login account as
NARC\Administrator.
> And the subscriber is in the HOT domain and Agent Login account is
> HOT\Administrator. No trusted can be established between them. What must I
> do to achieved successful pull subscription? How do I allow permissions
in
> the NARC domain for HOT\Administrator if there's no trusted' What about
> independent SQL server logins to access shares in NARC domain(How do I set
> it up if possible)?
> Thanks
>
> "Rand Boyd [MSFT]" <rboyd@.onlinemicrosoft.com> wrote in message
> news:fjJVvoV$DHA.3712@.cpmsftngxa06.phx.gbl...
> and
> access
> must
> by
> and
> failure.
rights.
>|||Hi Paul,
Can you please give me the links again. I cannot locate your
previous post. The only problem I am having is I cannot from the Subcriber
SQL Server access the Snapshot Folder in the Distributor SQL Server because
this is two different non-trusted domains.
"Paul Ibison" <Paul.Ibison@.Pygmalion.Com> wrote in message
news:eLNYLS8$DHA.2212@.TK2MSFTNGP10.phx.gbl...
> Joe,
> I haven't got Rand's post available here, but I would advise to either use
> SQL security or use pass-through authentication. Both are described in the
> link in my earlier post.
> Regards,
> Paul Ibison
>
> "Joe Mine" <huytuanattpgdotcomdotau> wrote in message
> news:u9ThB04$DHA.2216@.TK2MSFTNGP10.phx.gbl...
different
> SQL
> NARC\Administrator.
I
permissions
> in
about
set
share
problem
account
> rights.
>|||Try this article:
321822 HOW TO: Replicate Between Computers Running SQL Server in
Non-Trusted http://support.microsoft.com/?id=321822
Cindy Gross, MCDBA, MCSE
http://cindygross.tripod.com
This posting is provided "AS IS" with no warranties, and confers no rights.

OS backup

Hello.

New MSSQL guy coming from Oracle. I've read and understand that you can create backup files for a database using the server management studio.

However, I'm wondering if that is really necessary. Suppose I do not care about the loss of transaction logs, is copying the .mdf database files via OS command a viable backup strategy? If so do I need to bring down the database engine before starting the file copy?

Thanks a lot

You can get a valid backup of a SQL Server database by shutting down the instance and then taking a full OS backup, but you do lose significant functionality by doing so:

Obviously, you're giving up the ability to take your backups with the database online. Native SQL database backups are all online.|||Thank you Kevin.

Our production operations run on Oracle systems. We have to run 1 small MSSQL instance since some MSFT application only use that. So, I'm not really concerned about that DB's size, around-the-clock availibility, or point-in-time recovery.

Given the above requirements and the fact that I have no experience in MSSQL, backing up via the OS route seems to be the path of least resistence :)

Thanks again!