Showing posts with label master. Show all posts
Showing posts with label master. Show all posts

Saturday, February 25, 2012

mastlog.ldf

our mastlog.ldf file of Master database got deleted accidently by some user.
Is there anyway that the database could be started and new log file created
. master.mdf file is intact.
Thanks
ATDid you try restarting the server? If it won't start then you can rebuild
Master using the rebuildm utility (see Books Online for details). Then start
the server in single-user mode, restore Master from a backup (you do backup
the Master database don't you...?) or manually reattach your databases,
recreate logins, etc.
Make sure that the location of your database files is only accessible by the
administrator and the SQL Server service account so that this can't happen
again.
David Portas
SQL Server MVP
--|||David,
There is no backup available for master database. all I have is mdf file. Is
n't there any way that I can use this file to rebuild master database.
Thanks
AT|||HI
Maybe help for you:
I tested the following procedure, and successfully completed, but not guaran
tee your success.
And the future: Backup system databases periodically (daily)!
Copy to test server the master.mdf and rename
Use sp_attach_single_file_db wit another name than master (eg: NewMaser)
Use rebuilm.exe. (Copy SQL setup cd to hard disk and remove the read only fl
ag from files!)
Reinstall Service Packs and patches.
Stop the SQL server.
Create file backup from master.mdf and mastlog.ldf (Maybe You need restart
the restore)
Then start the server in single-user mode
--Like another way from here
Allow modifications to be made directly to the system catalogs
Update sysconfigures, syscurconfigs, tables from NewMaster database
Create insert statements and copy data from NewMaster to master database (US
E: WHERE NOT IN NEW MASTER..TABLE)
-sysaltfiles (or attach all production database and distribution if exist)
-sysservers (better: Recreate Linked Servers from documentation.)
-sysmessages (It is easy)
-sysxlogins (better: use the another way procedure for recreate logins)
-sysusers (or recreate users in master)
Disable modifications to be made directly to the system catalogs
Backup the master database
Test the server
Restart server
Backup master database
Another way:
-Recreate logins:
read the folowing: Microsoft Knowledge Base Article - 246133
< http://support.microsoft.com/defaul...133&Product=sql
>
Rewrite the sp_help_revlogin (use the attachaed database as source eg: FROM
master..sysxlogins --> FROM TESTSERVER.NewMaster.dbo.sysxlogins)
Recreate Linked Servers from documentation. (If You used remote server for r
eplication create linked server instead of remote)
Recreate users on master
Attach all production databases and distribution database.
Import custom sysmessages from NewMaster
Disable modifications to be made directly to the system catalogs
Backup the master database
Test the server
Restart server
Backup master database
At end:
Create scheduled backup for system databases.
And repair and repair until errors disappear. (The original values in NewMas
ter help You, do not drop!)
JBandi

Master-Details Insert

Master table (tlbProduct) having productID as Primary key and
which acts as reference key for table (tlbCategory).
Fields for tlbProduct are productID,productName
Fields for tlbCategort are productID,CategoryID(primary key),CategoryName,Prize
both productID,CategoryID are autoincrementing.
but when i write two inserts simultaneously as follows
insert into tlbProduct(productName)values(@.productName)
insert into tlbCategory(CategoryName,Prize) using sqldatasource
I get the error that ProductID value is null which is not provided
But (productId in both is autoincremented) and relationship is there in both tables
How to resolve this problem without adding ProductID in second Insert
?
SWati

Hello,

to create a relationship between two tables in sql, you need to match the primary key and the foreign key. So after the first insert, you would need to find out the id that was inserted by the database for the product (you can do this with SELECT SCOPE_IDENTITY()), and then you need to use this id in the second insert statement. If the keys don't match and the database is trying to enforce a relationship between the tables, you will get an error.

Good luck

Master-detail subreports and performance.

If I create a master detail-report using subreports, will a separate query
run for each subreport at the time it loads? Lets say I have a report with
500 master rows, will it have to run 500 queries for the subreports before
the first page loads?
I know there is no on-demand subreport load, and from what I read you can't
do a heterogeneos joins between 2 record sets in the same report - so that
the detail recordset would filter under each master row based on an id.
So what is the best way to produce a large master-detail report with
reasonable performance?
Thanks.You are correct, the subreport is executed for each master record. Other
than making sure your database is optimized (correct indexes for example)
there isn't much you can do to speed it up the report running. However, if
the report is only needed for a particular time (for instance, this report
is run daily) you could use snapshots. Read up on that in books online.
The other possibility is to consider drill through. In that case you show
the master tables with a link that when the user wants additional data they
click on the link and use jump to report to pull up the additional data.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"David W" <spivey@.nospam.post.com> wrote in message
news:eSsZCOqlHHA.4628@.TK2MSFTNGP06.phx.gbl...
> If I create a master detail-report using subreports, will a separate query
> run for each subreport at the time it loads? Lets say I have a report
> with 500 master rows, will it have to run 500 queries for the subreports
> before the first page loads?
> I know there is no on-demand subreport load, and from what I read you
> can't do a heterogeneos joins between 2 record sets in the same report -
> so that the detail recordset would filter under each master row based on
> an id.
> So what is the best way to produce a large master-detail report with
> reasonable performance?
> Thanks.
>|||Thanks Bruce for confirming my suspicions. I'm definitely not doing a
report that generates over 500 queries to load a page regardless of database
optimizations or snapshot usage.
Well, I ended up doing a SQL join between my master recordset query and my
detail recordset query to produce one mammoth recordset containing all
fields. Then I grouped on the master columns, and displayed the detail
records as expandable sections. Its not efficient by any means but it works
reasonably well, and its only a single query, and it gives me the
master-detail effect.
Any idea when we are going to see the next version of Reporting Services.
"Bruce L-C [MVP]" <bruce_lcNOSPAM@.hotmail.com> wrote in message
news:%23AwSqovlHHA.4552@.TK2MSFTNGP04.phx.gbl...
> You are correct, the subreport is executed for each master record. Other
> than making sure your database is optimized (correct indexes for example)
> there isn't much you can do to speed it up the report running. However, if
> the report is only needed for a particular time (for instance, this report
> is run daily) you could use snapshots. Read up on that in books online.
> The other possibility is to consider drill through. In that case you show
> the master tables with a link that when the user wants additional data
> they click on the link and use jump to report to pull up the additional
> data.
>
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
> "David W" <spivey@.nospam.post.com> wrote in message
> news:eSsZCOqlHHA.4628@.TK2MSFTNGP06.phx.gbl...
>> If I create a master detail-report using subreports, will a separate
>> query run for each subreport at the time it loads? Lets say I have a
>> report with 500 master rows, will it have to run 500 queries for the
>> subreports before the first page loads?
>> I know there is no on-demand subreport load, and from what I read you
>> can't do a heterogeneos joins between 2 record sets in the same report -
>> so that the detail recordset would filter under each master row based on
>> an id.
>> So what is the best way to produce a large master-detail report with
>> reasonable performance?
>> Thanks.
>|||What you are explaining here is drill down. It is a nice user interface but
not one I do too often because of the amount of data returned.
I would consider looking into using drill through in the future. Users are
very comfortable with it and you get really good performance.
The next release of RS (non-service pack) is with Katmai (next version of
SQL Server). RS is part of SQL Server and releases with both service packs
and major releases for SQL Server. Early on this was not true but now it is
totally in sync with the rest of SQL Server.
http://www.microsoft.com/presspass/press/2007/may07/05-09KatmaiPR.mspx
Right now they are just saying 2008.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"David W" <spivey@.nospam.post.com> wrote in message
news:u4QXU2vlHHA.3872@.TK2MSFTNGP04.phx.gbl...
> Thanks Bruce for confirming my suspicions. I'm definitely not doing a
> report that generates over 500 queries to load a page regardless of
> database optimizations or snapshot usage.
> Well, I ended up doing a SQL join between my master recordset query and my
> detail recordset query to produce one mammoth recordset containing all
> fields. Then I grouped on the master columns, and displayed the detail
> records as expandable sections. Its not efficient by any means but it
> works reasonably well, and its only a single query, and it gives me the
> master-detail effect.
> Any idea when we are going to see the next version of Reporting Services.
>
>
> "Bruce L-C [MVP]" <bruce_lcNOSPAM@.hotmail.com> wrote in message
> news:%23AwSqovlHHA.4552@.TK2MSFTNGP04.phx.gbl...
>> You are correct, the subreport is executed for each master record. Other
>> than making sure your database is optimized (correct indexes for example)
>> there isn't much you can do to speed it up the report running. However,
>> if the report is only needed for a particular time (for instance, this
>> report is run daily) you could use snapshots. Read up on that in books
>> online.
>> The other possibility is to consider drill through. In that case you show
>> the master tables with a link that when the user wants additional data
>> they click on the link and use jump to report to pull up the additional
>> data.
>>
>> --
>> Bruce Loehle-Conger
>> MVP SQL Server Reporting Services
>> "David W" <spivey@.nospam.post.com> wrote in message
>> news:eSsZCOqlHHA.4628@.TK2MSFTNGP06.phx.gbl...
>> If I create a master detail-report using subreports, will a separate
>> query run for each subreport at the time it loads? Lets say I have a
>> report with 500 master rows, will it have to run 500 queries for the
>> subreports before the first page loads?
>> I know there is no on-demand subreport load, and from what I read you
>> can't do a heterogeneos joins between 2 record sets in the same report -
>> so that the detail recordset would filter under each master row based on
>> an id.
>> So what is the best way to produce a large master-detail report with
>> reasonable performance?
>> Thanks.
>>
>

MasterDB

After I restore the Master db from server A into Server B
The SQL 2K (Standard edition)service does not want to
start.
Server A and B have the same SQL version and build, SP.
what seems wrong?got any error?
"sdl" <anonymous@.discussions.microsoft.com> wrote in message
news:63cd01c40154$06b25e50$a301280a@.phx.gbl...
> After I restore the Master db from server A into Server B
> The SQL 2K (Standard edition)service does not want to
> start.
> Server A and B have the same SQL version and build, SP.
> what seems wrong?
>|||Hi,
Can you please attach the SQL server error log, file will be in sql server
program directory\log folder.
The reasson for this problem might be ,
1. The physical files for system databases (Model, TEMPDB, MSDB) might be in
diffrent location for the SERVER A. so
after restore in Server B during start up SQL Server will not be able to get
the files and resulted in failure.
Tahnks
Hari
MCDBA
"sdl" <anonymous@.discussions.microsoft.com> wrote in message
news:63cd01c40154$06b25e50$a301280a@.phx.gbl...
> After I restore the Master db from server A into Server B
> The SQL 2K (Standard edition)service does not want to
> start.
> Server A and B have the same SQL version and build, SP.
> what seems wrong?
>

MasterDB

After I restore the Master db from server A into Server B
The SQL 2K (Standard edition)service does not want to
start.
Server A and B have the same SQL version and build, SP.
what seems wrong?got any error?
"sdl" <anonymous@.discussions.microsoft.com> wrote in message
news:63cd01c40154$06b25e50$a301280a@.phx.gbl...
> After I restore the Master db from server A into Server B
> The SQL 2K (Standard edition)service does not want to
> start.
> Server A and B have the same SQL version and build, SP.
> what seems wrong?
>|||Hi,
Can you please attach the SQL server error log, file will be in sql server
program directory\log folder.
The reasson for this problem might be ,
1. The physical files for system databases (Model, TEMPDB, MSDB) might be in
diffrent location for the SERVER A. so
after restore in Server B during start up SQL Server will not be able to get
the files and resulted in failure.
Tahnks
Hari
MCDBA
"sdl" <anonymous@.discussions.microsoft.com> wrote in message
news:63cd01c40154$06b25e50$a301280a@.phx.gbl...
> After I restore the Master db from server A into Server B
> The SQL 2K (Standard edition)service does not want to
> start.
> Server A and B have the same SQL version and build, SP.
> what seems wrong?
>

master4IDR ??

Does anyone know what the "4IDR" databases are? (Master/Model/MSDB)
MSSQL Log entry: Starting up database 'master4IDR'.
I do see the .mdf & .ldf, but I have no such db on this server.
What are these databases?
Thanx!
I've never see any such animals. My guess is that some 3rd party tool (like backup sw or similar)
has created these.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"JLS" <jlshoop@.hotmail.com> wrote in message news:eYXq6WBIFHA.2620@.tk2msftngp13.phx.gbl...
Does anyone know what the "4IDR" databases are? (Master/Model/MSDB)
MSSQL Log entry: Starting up database 'master4IDR'.
I do see the .mdf & .ldf, but I have no such db on this server.
What are these databases?
Thanx!
|||I did a google search on 'masteri4dr' and got several, but inconclusive,
hits. Many referred to third party backup software.
Try running the query below to identify the databases associated with these
files.
SELECT *
FROM master..sysaltfiles
WHERE filename LIKE '%4IDR.mdf%'
Hope this helps.
Dan Guzman
SQL Server MVP
"JLS" <jlshoop@.hotmail.com> wrote in message
news:eYXq6WBIFHA.2620@.tk2msftngp13.phx.gbl...
Does anyone know what the "4IDR" databases are? (Master/Model/MSDB)
MSSQL Log entry: Starting up database 'master4IDR'.
I do see the .mdf & .ldf, but I have no such db on this server.
What are these databases?
Thanx!

master4IDR ??

Does anyone know what the "4IDR" databases are? (Master/Model/MSDB)
MSSQL Log entry: Starting up database 'master4IDR'.
I do see the .mdf & .ldf, but I have no such db on this server.
What are these databases?
Thanx!I've never see any such animals. My guess is that some 3rd party tool (like
backup sw or similar)
has created these.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"JLS" <jlshoop@.hotmail.com> wrote in message news:eYXq6WBIFHA.2620@.tk2msftng
p13.phx.gbl...
Does anyone know what the "4IDR" databases are? (Master/Model/MSDB)
MSSQL Log entry: Starting up database 'master4IDR'.
I do see the .mdf & .ldf, but I have no such db on this server.
What are these databases?
Thanx!|||I did a google search on 'masteri4dr' and got several, but inconclusive,
hits. Many referred to third party backup software.
Try running the query below to identify the databases associated with these
files.
SELECT *
FROM master..sysaltfiles
WHERE filename LIKE '%4IDR.mdf%'
Hope this helps.
Dan Guzman
SQL Server MVP
"JLS" <jlshoop@.hotmail.com> wrote in message
news:eYXq6WBIFHA.2620@.tk2msftngp13.phx.gbl...
Does anyone know what the "4IDR" databases are? (Master/Model/MSDB)
MSSQL Log entry: Starting up database 'master4IDR'.
I do see the .mdf & .ldf, but I have no such db on this server.
What are these databases?
Thanx!

Master/Detail table insertion.

Hi Experts,

I need to know the best approach to save data in master table and then in detail table.
I know this method but i know it's not a good approach why i will explain

Insertion in Master Table..................................... A

Insertion in Detail Table........................................B

Now if there is any exception occurred while step A then the step B will not take place which is ok but if there is exception while step B then the process A will have completed
i.e the data in master table will be Inserted/Deleted/Updated but there will not be a corresponding action in Detail table which is not good approach.

So please can any one tell me a good approach for this.

This my solution using trigger and SET XACT_ABORT ::

create table A (a int)

go

create table B (a int)

create trigger t_A on A

after insert

as

set xact_abort off

if @.@.error <>0

begin

print 'error in master'

rollback tran

else

begin

commit tran

insert into b

select a from inserted

-- values ('gigi')

end

if you run

insert into a values (1) the value 1 is inserted in A and B

for testing how is behavior on error of inserting in B table, unn comment "-- values ('gigi')" and comment " select a from inserted " and run the command " alter triger t_A ...." ()modifying trigger)

if you run insert into a values (2) the value 2 will be insert in A table and inserting will not be possible in B table because is an error .

So you have to modify the operation of inserting in B

" insert into b

select a from inserted

-- values ('gigi')

"

as your business logic request.

|||

Thanks for the reply but i dont want to use trigers because it can affect the performance.

Thanks for giving time.

|||

Did you calculate how is affected the performance ? Obviously the trigger have to be avoided but in some cases it is usually.

|||You'll probably want to encapsulate the inserts within a transaction with logic to perform a ROLLBACK if anything goes wrong or a COMMIT when all of the work is complete.

There is a vast amount of information in Books Online on transaction management.

Put simply your logic might look something like this.

BEGIN TRANSACTION

INSERT INTO A
INSERT INTO B
INSERT INTO B
INSERT INTO B

IF NO ERROR THEN

COMMIT ELSE
ROLLBACK


|||Thanks Sir,

Please can u explain that how can i send array because according to your solution i will have to use array for my detail information for example if my master table is ORDER and my detail table is ORDER_DETAIL then the list of products are to be send in array which i dont know how will i do.

If you can provide a simple code i will be thankfull to you.

Thanks.

Monday, February 20, 2012

Master/Detail table insertion.

Hi Experts,

I need to know the best approach to save data in master table and then in detail table.
I know this method but i know it's not a good approach why i will explain

Insertion in Master Table..................................... A

Insertion in Detail Table........................................B

Now if there is any exception occurred while step A then the step B will not take place which is ok but if there is exception while step B then the process A will have completed
i.e the data in master table will be Inserted/Deleted/Updated but there will not be a corresponding action in Detail table which is not good approach.

So please can any one tell me a good approach for this.

This my solution using trigger and SET XACT_ABORT ::

create table A (a int)

go

create table B (a int)

create trigger t_A on A

after insert

as

set xact_abort off

if @.@.error <>0

begin

print 'error in master'

rollback tran

else

begin

commit tran

insert into b

select a from inserted

-- values ('gigi')

end

if you run

insert into a values (1) the value 1 is inserted in A and B

for testing how is behavior on error of inserting in B table, unn comment "-- values ('gigi')" and comment " select a from inserted " and run the command " alter triger t_A ...." ()modifying trigger)

if you run insert into a values (2) the value 2 will be insert in A table and inserting will not be possible in B table because is an error .

So you have to modify the operation of inserting in B

" insert into b

select a from inserted

-- values ('gigi')

"

as your business logic request.

|||

Thanks for the reply but i dont want to use trigers because it can affect the performance.

Thanks for giving time.

|||

Did you calculate how is affected the performance ? Obviously the trigger have to be avoided but in some cases it is usually.

|||You'll probably want to encapsulate the inserts within a transaction with logic to perform a ROLLBACK if anything goes wrong or a COMMIT when all of the work is complete.

There is a vast amount of information in Books Online on transaction management.

Put simply your logic might look something like this.

BEGIN TRANSACTION

INSERT INTO A
INSERT INTO B
INSERT INTO B
INSERT INTO B

IF NO ERROR THEN

COMMIT ELSE
ROLLBACK


|||Thanks Sir,

Please can u explain that how can i send array because according to your solution i will have to use array for my detail information for example if my master table is ORDER and my detail table is ORDER_DETAIL then the list of products are to be send in array which i dont know how will i do.

If you can provide a simple code i will be thankfull to you.

Thanks.

Master/Detail Query - Got confused

Hallo all,

I’ve two tables (Order_Headers and Order_Details) in SQL Server 2005:

Order_Headers

DocType Order#SubTotalVATTotal

01110018118

01220036236

Order_Details

Order#Line# QTY SKUUnit_Price

111A30

121B70

211C40

221D100

231E60

I need to query both tables and return Master/Detail XML with the following format, ie. Need to return all order lines for a particular order header#. I’m using FOR XML PATH('Document'), ROOT('XML_QueryDocument') but I’m not able to add the “<LineItem>” tag for each order line.

<XML_QueryDocument>

<Document>

<DocType>01</DocumentType>

<OrderNumber>1</OrderNumber>

<SubTotal>100</SubTotal>

<VAT>18</VAT>

<Total>118</Total>

<LineItem>

<LineNumber>1</LineNumber>

<QTY>1</QTY>

<SKU>A</SKU>

<Unit_Price>30</Unit_Price>

</LineItem>

<LineItem>

<LineNumber>2</LineNumber>

<QTY>1</QTY>

<SKU>B</SKU>

<Unit_Price>70</Unit_Price>

</LineItem>

</Document>

</XML_QueryDocument>

Could anyone please shed some light on how to accomplish this? I think I need several SELECT statements but I got confused.

Thanks in advance,

ST

Code Snippet

CREATE TABLE #Order_Headers(DocType int, OrderNum int, SubTotal int, VAT int, Total int)

CREATE TABLE #Order_Detail(OrderNum int, LineNum int, QTY int, SKU char(10), UnitPrice int)

INSERT INTO #Order_Headers SELECT 1, 1, 100, 18, 118

INSERT INTO #Order_Headers SELECT 1, 2, 200, 36, 236

INSERT INTO #Order_Detail SELECT 1, 1, 1, 'A', 30

INSERT INTO #Order_Detail SELECT 2, 1, 1, 'B', 70

INSERT INTO #Order_Detail SELECT 1, 1, 1, 'C', 40

INSERT INTO #Order_Detail SELECT 3, 1, 1, 'D', 100

INSERT INTO #Order_Detail SELECT 4, 1, 1, 'E', 60

SELECT * FROM #Order_Headers oh

FULL OUTER JOIN #Order_Detail od on oh.OrderNum = od.OrderNum

DROP TABLE #Order_Headers

DROP TABLE #Order_Detail

Adamus

|||

Thanks Adamus for your prompt reply!

If I add FOR XML PATH('Document'), ROOT('XML_QueryDocument') at the end of the SELECT statement, I get the following.

It's repeating tags DocType, OrderNum, SubTotal for each order line. This is exactly what I wanted left out. I think the query needs to create a LineItem tag for each order line and show the order header just once either at the top or at the bottom inside a <document> tag. This is where I got confused.

Thanks,

ST

<XML_QueryDocument>
<Document>
<DocType>1</DocType>
<OrderNum>1</OrderNum>
<SubTotal>100</SubTotal>
<VAT>18</VAT>
<Total>118</Total>
<OrderNum>1</OrderNum>
<LineNum>1</LineNum>
<QTY>1</QTY>
<SKU>A </SKU>
<UnitPrice>30</UnitPrice>
</Document>
<Document>
<DocType>1</DocType>
<OrderNum>1</OrderNum>
<SubTotal>100</SubTotal>
<VAT>18</VAT>
<Total>118</Total>
<OrderNum>1</OrderNum>
<LineNum>1</LineNum>
<QTY>1</QTY>
<SKU>C </SKU>
<UnitPrice>40</UnitPrice>
</Document>

.......

|||

Perhaps something like this:

Code Snippet

SELECT
Orders.DocType,
Orders.OrderNum,
Orders.SubTotal,
Orders.VAT,
Orders.Total,
LineItem.LineNum,
LineItem.QTY,
LineItem.SKU,
LineItem.UnitPrice
FROM #Order_Headers Orders
JOIN #Order_Detail LineItem
ON Orders.OrderNum = LineItem.OrderNum
FOR XML AUTO, ELEMENTS

XML_F52E2B61-18A1-11d1-B105-00805F49916B
--
<Orders>
<DocType>1</DocType>
<OrderNum>1</OrderNum>
<SubTotal>100</SubTotal>
<VAT>18</VAT>
<Total>118</Total>
<LineItem>
<LineNum>1</LineNum>
<QTY>1</QTY>
<SKU>A </SKU>
<UnitPrice>30</UnitPrice>
</LineItem>
</Orders>
{etc.}

|||

Thanks Arnie also for a good insight.

I modified the code a little bit as the code above doesn't produce well-formed XML (it shows "XML document cannot contain multiple root level elements"). I've also changed the INSERT on #Order_Detail for order# 1 to have 3 lines

Since I only need to return a document at the time I just added a WHERE clause and that's exactly what I need.

Here's the code just in case someone else is after this also:

CREATE TABLE #Order_Headers(DocType int, OrderNum int, SubTotal int, VAT int, Total int)
CREATE TABLE #Order_Detail(OrderNum int, LineNum int, QTY int, SKU char(10), UnitPrice int)

INSERT INTO #Order_Headers SELECT 1, 1, 100, 18, 118
INSERT INTO #Order_Headers SELECT 1, 2, 200, 36, 236

INSERT INTO #Order_Detail SELECT 1, 1, 10, 'A', 30
INSERT INTO #Order_Detail SELECT 1, 2, 20, 'B', 700
INSERT INTO #Order_Detail SELECT 1, 3, 30, 'C', 4000
INSERT INTO #Order_Detail SELECT 3, 1, 1, 'D', 100
INSERT INTO #Order_Detail SELECT 4, 1, 1, 'E', 60

SELECT
Orders.DocType,
Orders.OrderNum,
Orders.SubTotal,
Orders.VAT,
Orders.Total,
LineItem.LineNum,
LineItem.QTY,
LineItem.SKU,
LineItem.UnitPrice
FROM #Order_Headers Orders
JOIN #Order_Detail LineItem
ON Orders.OrderNum = LineItem.OrderNum
WHERE Orders.OrderNum = 1
FOR XML AUTO, ELEMENTS


DROP TABLE #Order_Headers
DROP TABLE #Order_Detail

master/Child Deployment

Hi Guru's,

I am facing a problem in deploying the SSIS packages.

My Scenario is like this

1. Have one Master SSIS Package.

2. Master SSIS Package inturn calls 3 Different packages using execute package task.

3. I have a common Configuration file for all these packages.

4. I am using File System deployment.

5. I have imported all the packages i.e master and the 3 child packages using SQL Server management studio.

6. Now i have created a job, and added the master package as a step.

7. I have a variable declared in the configuration file and the child packages will be getting their path from this variable.

The problem since i know the imported packages lies in "C:\Program Files\Microsoft SQL Server\90\DTS\Packages\<<Folder Name>>" i have poited the child package variable to point to this directory.

I still want to import all the packages and want to get this directory info dynamically thorugh the script so that i can assign this at run time.

I am using "Directory.GetCurrentDirectory" But it's giving me a different location when we run the master package.

Can any one has any idea or comments how to retrive the path of the master package?

Even a work around or any other option is also fine....

Regads,

Dev

I may not be clear on your requirements, but here's what I do:

I have a configuration file that is used by all packages, for database connections and whatnot, and a I have one that is specifically for the master. If any of the child packages need anything from the master configuration file, the master package will pass the information down to them.

The master has a variable named ChildPackagePath which is the folder location of the child packages. This variable is set by the master's configuration file. I then use expressions on the connection managers to the child packages to set the Connection String property as @.ChildPackagePath + "packagname.dtsx".

This allows you to vary the location of the child packages by the server environment. I don't think that determining the package location dynamically at runtime is possible. Your best bet is to use a path defined in a configuration file, or use a path that is dynamically available in an environment variable such as USERPROFILE.

master.mdf recovery

Is it possible to recover master database from problematic master.mdf and/or
problematic mastlog.ldf? No backups exist. The error that appeared in event
log is
Error:9003, Severity:20, State 1. and right after that: "Cannot recover
master database.Exiting" . The reason I am posting this is that I know there
is something starnge going on because there was no hard disk failure and the
problem appeared after power loss of the server. But scan disk did not report
any problem when the server rebooted after the power loss. So maybe the file
is "not so corrupted" or maybe it is a fixable problem. Thank you in advance.Hi
9003: The LSN %S_LSN passed to log scan in database '%.*ls' is invalid.
You have corruption. SQL server might have been in the middle of writing to
the DB when the power outage occured. This can corrupt the DB.
Without a backup of Master, you are high and dry. Your only option is the
run the Rebuild Wizard (Rebuildm.exe), but you loose all your user logins.
Look up the topic in BOL.
Regards
Mike
"Radis Bill" wrote:
> Is it possible to recover master database from problematic master.mdf and/or
> problematic mastlog.ldf? No backups exist. The error that appeared in event
> log is
> Error:9003, Severity:20, State 1. and right after that: "Cannot recover
> master database.Exiting" . The reason I am posting this is that I know there
> is something starnge going on because there was no hard disk failure and the
> problem appeared after power loss of the server. But scan disk did not report
> any problem when the server rebooted after the power loss. So maybe the file
> is "not so corrupted" or maybe it is a fixable problem. Thank you in advance.|||From the console, you might be able to start sqlservr with the -T3607
option. The recovers non of the databases, system nor users. This may
allow you to export the configuration contexts from the system tables from
within the master database. If you do this, then there is a chance that you
would have all the information necessary to replace the content on a rebuilt
master. However, THIS IS A COMPLICATED SITUATION. CALL MS PSS FOR
ASSISTANCE.
Sincerely,
Anthony Thomas
"Radis Bill" <Radis Bill@.discussions.microsoft.com> wrote in message
news:63EFB560-DFC7-4D36-B331-62846758B058@.microsoft.com...
Is it possible to recover master database from problematic master.mdf and/or
problematic mastlog.ldf? No backups exist. The error that appeared in event
log is
Error:9003, Severity:20, State 1. and right after that: "Cannot recover
master database.Exiting" . The reason I am posting this is that I know there
is something starnge going on because there was no hard disk failure and the
problem appeared after power loss of the server. But scan disk did not
report
any problem when the server rebooted after the power loss. So maybe the file
is "not so corrupted" or maybe it is a fixable problem. Thank you in
advance.

master.mdf recovery

Is it possible to recover master database from problematic master.mdf and/or
problematic mastlog.ldf? No backups exist. The error that appeared in event
log is
Error:9003, Severity:20, State 1. and right after that: "Cannot recover
master database.Exiting" . The reason I am posting this is that I know there
is something starnge going on because there was no hard disk failure and the
problem appeared after power loss of the server. But scan disk did not report
any problem when the server rebooted after the power loss. So maybe the file
is "not so corrupted" or maybe it is a fixable problem. Thank you in advance.
Hi
9003: The LSN %S_LSN passed to log scan in database '%.*ls' is invalid.
You have corruption. SQL server might have been in the middle of writing to
the DB when the power outage occured. This can corrupt the DB.
Without a backup of Master, you are high and dry. Your only option is the
run the Rebuild Wizard (Rebuildm.exe), but you loose all your user logins.
Look up the topic in BOL.
Regards
Mike
"Radis Bill" wrote:

> Is it possible to recover master database from problematic master.mdf and/or
> problematic mastlog.ldf? No backups exist. The error that appeared in event
> log is
> Error:9003, Severity:20, State 1. and right after that: "Cannot recover
> master database.Exiting" . The reason I am posting this is that I know there
> is something starnge going on because there was no hard disk failure and the
> problem appeared after power loss of the server. But scan disk did not report
> any problem when the server rebooted after the power loss. So maybe the file
> is "not so corrupted" or maybe it is a fixable problem. Thank you in advance.
|||From the console, you might be able to start sqlservr with the -T3607
option. The recovers non of the databases, system nor users. This may
allow you to export the configuration contexts from the system tables from
within the master database. If you do this, then there is a chance that you
would have all the information necessary to replace the content on a rebuilt
master. However, THIS IS A COMPLICATED SITUATION. CALL MS PSS FOR
ASSISTANCE.
Sincerely,
Anthony Thomas

"Radis Bill" <Radis Bill@.discussions.microsoft.com> wrote in message
news:63EFB560-DFC7-4D36-B331-62846758B058@.microsoft.com...
Is it possible to recover master database from problematic master.mdf and/or
problematic mastlog.ldf? No backups exist. The error that appeared in event
log is
Error:9003, Severity:20, State 1. and right after that: "Cannot recover
master database.Exiting" . The reason I am posting this is that I know there
is something starnge going on because there was no hard disk failure and the
problem appeared after power loss of the server. But scan disk did not
report
any problem when the server rebooted after the power loss. So maybe the file
is "not so corrupted" or maybe it is a fixable problem. Thank you in
advance.

master.mdf recovery

Is it possible to recover master database from problematic master.mdf and/or
problematic mastlog.ldf? No backups exist. The error that appeared in event
log is
Error:9003, Severity:20, State 1. and right after that: "Cannot recover
master database.Exiting" . The reason I am posting this is that I know there
is something starnge going on because there was no hard disk failure and the
problem appeared after power loss of the server. But scan disk did not repor
t
any problem when the server rebooted after the power loss. So maybe the file
is "not so corrupted" or maybe it is a fixable problem. Thank you in advance
.Hi
9003: The LSN %S_LSN passed to log scan in database '%.*ls' is invalid.
You have corruption. SQL server might have been in the middle of writing to
the DB when the power outage occured. This can corrupt the DB.
Without a backup of Master, you are high and dry. Your only option is the
run the Rebuild Wizard (Rebuildm.exe), but you loose all your user logins.
Look up the topic in BOL.
Regards
Mike
"Radis Bill" wrote:
[vbcol=seagreen]
> Is it possible to recover master database from problematic master.mdf and/
or
> problematic mastlog.ldf? No backups exist. The error that appeared in even
t
> log is
> Error:9003, Severity:20, State 1. and right after that: "Cannot recover
> master database.Exiting" . The reason I am posting this is that I know the
re
> is something starnge going on because there was no hard disk failure and t
he
> problem appeared after power loss of the server. But scan disk did not rep
ort
> any problem when the server rebooted after the power loss. So maybe the fi
le
> is "not so corrupted" or maybe it is a fixable problem. Thank you in advance.[/vbc
ol]|||From the console, you might be able to start sqlservr with the -T3607
option. The recovers non of the databases, system nor users. This may
allow you to export the configuration contexts from the system tables from
within the master database. If you do this, then there is a chance that you
would have all the information necessary to replace the content on a rebuilt
master. However, THIS IS A COMPLICATED SITUATION. CALL MS PSS FOR
ASSISTANCE.
Sincerely,
Anthony Thomas
"Radis Bill" <Radis Bill@.discussions.microsoft.com> wrote in message
news:63EFB560-DFC7-4D36-B331-62846758B058@.microsoft.com...
Is it possible to recover master database from problematic master.mdf and/or
problematic mastlog.ldf? No backups exist. The error that appeared in event
log is
Error:9003, Severity:20, State 1. and right after that: "Cannot recover
master database.Exiting" . The reason I am posting this is that I know there
is something starnge going on because there was no hard disk failure and the
problem appeared after power loss of the server. But scan disk did not
report
any problem when the server rebooted after the power loss. So maybe the file
is "not so corrupted" or maybe it is a fixable problem. Thank you in
advance.

master.INFORMATION_SCHEMA.SCHEMATA

Is is just me or does this query produce the wrong results?
SELECT CATALOG_NAME FROM master.INFORMATION_SCHEMA.SCHEMATA
I have a MSDE sp3a installation, and this query does not include my user
database in the resut set.
hi,
Wozza wrote:
> Is is just me or does this query produce the wrong results?
> SELECT CATALOG_NAME FROM master.INFORMATION_SCHEMA.SCHEMATA
> I have a MSDE sp3a installation, and this query does not include my
> user database in the resut set.
yes... it seems to work only when running in the user's database context,
and only for the specifi user's database..
CREATE DATABASE a
CREATE DATABASE b
if run on "b" database context it returns
USE b
SELECT CATALOG_NAME FROM master.INFORMATION_SCHEMA.SCHEMATA
CATALOG_NAME
master
tempdb
model
msdb
b
(5 row(s) affected)
seems to be a problem in the
WHERE
a_cha.type = 1001 -- type is charset
AND a_cha.id = convert(tinyint, DatabasePropertyEx(db.name, 'sqlcharset'))
filter of the view,
select
db.name as CATALOG_NAME
,USER_NAME() as SCHEMA_NAME
,USER_NAME() as SCHEMA_OWNER
,convert(sysname, NULL) as DEFAULT_CHARACTER_SET_CATALOG
,convert(sysname, NULL) as DEFAULT_CHARACTER_SET_SCHEMA
,a_cha.name as DEFAULT_CHARACTER_SET_NAME
FROM
master.dbo.sysdatabases db,
master.dbo.syscharsets a_cha --charset/1001, not sortorder.
WHERE
a_cha.type = 1001 -- type is charset
AND a_cha.id = convert(tinyint, DatabasePropertyEx(db.name, 'sqlcharset'))
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
DbaMgr2k ver 0.11.1 - DbaMgr ver 0.57.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply
|||ok... SQL Server MVP Jasper Smith expanded this reporting it a a "known
issue" of that ANSI view, depending on the autoclose property (default on
MSDE) of the database(s), that causes them to not appear in the
INFORMATION_SCHEMA.SCHEMATA view
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
DbaMgr2k ver 0.11.1 - DbaMgr ver 0.57.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply

Master..sysservers

Hey all,
My question is: Is it possible for the master..sysservers
table to be empty? I am running a job which requires
connection to all my other sql servers but i am unable to
because : Server: Msg 7202, Level 11, State 2, Line 1
Could not find server 'XXXX' in sysservers. Execute
sp_addlinkedserver to add the server to sysservers.
This job usto work perfectly. This server is a production
server and rebooting it might not be the best option. Any
one got any ideas?Claudy,
I don't believe the table can be empty. Though I can not find a document
about it, the table should at least contain the local server with id = 0. I
use this table for some of my tasks and have always been assuming that the
local server is there, and it has been working.
As of your problem, the error message does not say that the table is empty.
It says it could not find the remote server. If the access of the remote
server is called for by an application, you may have the linked server
removed. If the application is cycling through the table for linked
servers, the linked server may not be running or the network is not
functioning. There might be other problems, so be sure checking beyond the
sysserver table.
Quentin
"Claudy" <alphaseusa@.hotmail.com> wrote in message
news:068a01c396e8$dc2de440$a501280a@.phx.gbl...
> Hey all,
> My question is: Is it possible for the master..sysservers
> table to be empty? I am running a job which requires
> connection to all my other sql servers but i am unable to
> because : Server: Msg 7202, Level 11, State 2, Line 1
> Could not find server 'XXXX' in sysservers. Execute
> sp_addlinkedserver to add the server to sysservers.
> This job usto work perfectly. This server is a production
> server and rebooting it might not be the best option. Any
> one got any ideas?

Master..sysaltfiles contains incorrect info

Dear all,
I had a database which contained 2 log files, one of the log files was
deleted - however, master..sysaltfiles still shows 2 log files in
existance...
The database is open, and working OK, so second log file is definately not
being used ( it no longer exists on disk)...
So how do I update master..sysaltfiles to be correct ?
I restarted SQL Server, did not resolve issue ( ie sysaltfiles still shows 2
files) . I'm loathe to do a direct delete on master..sysaltfiles until I can
discover if this kind of 'corruption' is not unknown... but do I have any
other choice ?
Hi
I don't know why you have got the extra entry, was there any message in the
SQL Server log when you re-started?
What happens when you try to remove the file using:
ALTER DATABASE database REMOVE FILE logical_file_name
John
"SteveH" <SteveH@.discussions.microsoft.com> wrote in message
news:7C75A085-7563-4D94-9E50-353ECAFF820B@.microsoft.com...
> Dear all,
> I had a database which contained 2 log files, one of the log files was
> deleted - however, master..sysaltfiles still shows 2 log files in
> existance...
> The database is open, and working OK, so second log file is definately not
> being used ( it no longer exists on disk)...
> So how do I update master..sysaltfiles to be correct ?
> I restarted SQL Server, did not resolve issue ( ie sysaltfiles still shows
> 2
> files) . I'm loathe to do a direct delete on master..sysaltfiles until I
> can
> discover if this kind of 'corruption' is not unknown... but do I have any
> other choice ?

Master..sysaltfiles contains incorrect info

Dear all,
I had a database which contained 2 log files, one of the log files was
deleted - however, master..sysaltfiles still shows 2 log files in
existance...
The database is open, and working OK, so second log file is definately not
being used ( it no longer exists on disk)...
So how do I update master..sysaltfiles to be correct ?
I restarted SQL Server, did not resolve issue ( ie sysaltfiles still shows 2
files) . I'm loathe to do a direct delete on master..sysaltfiles until I can
discover if this kind of 'corruption' is not unknown... but do I have any
other choice ?Hi
I don't know why you have got the extra entry, was there any message in the
SQL Server log when you re-started?
What happens when you try to remove the file using:
ALTER DATABASE database REMOVE FILE logical_file_name
John
"SteveH" <SteveH@.discussions.microsoft.com> wrote in message
news:7C75A085-7563-4D94-9E50-353ECAFF820B@.microsoft.com...
> Dear all,
> I had a database which contained 2 log files, one of the log files was
> deleted - however, master..sysaltfiles still shows 2 log files in
> existance...
> The database is open, and working OK, so second log file is definately not
> being used ( it no longer exists on disk)...
> So how do I update master..sysaltfiles to be correct ?
> I restarted SQL Server, did not resolve issue ( ie sysaltfiles still shows
> 2
> files) . I'm loathe to do a direct delete on master..sysaltfiles until I
> can
> discover if this kind of 'corruption' is not unknown... but do I have any
> other choice ?

Master..sysaltfiles contains incorrect info

Dear all,
I had a database which contained 2 log files, one of the log files was
deleted - however, master..sysaltfiles still shows 2 log files in
existance...
The database is open, and working OK, so second log file is definately not
being used ( it no longer exists on disk)...
So how do I update master..sysaltfiles to be correct ?
I restarted SQL Server, did not resolve issue ( ie sysaltfiles still shows 2
files) . I'm loathe to do a direct delete on master..sysaltfiles until I can
discover if this kind of 'corruption' is not unknown... but do I have any
other choice ?Hi
I don't know why you have got the extra entry, was there any message in the
SQL Server log when you re-started?
What happens when you try to remove the file using:
ALTER DATABASE database REMOVE FILE logical_file_name
John
"SteveH" <SteveH@.discussions.microsoft.com> wrote in message
news:7C75A085-7563-4D94-9E50-353ECAFF820B@.microsoft.com...
> Dear all,
> I had a database which contained 2 log files, one of the log files was
> deleted - however, master..sysaltfiles still shows 2 log files in
> existance...
> The database is open, and working OK, so second log file is definately not
> being used ( it no longer exists on disk)...
> So how do I update master..sysaltfiles to be correct ?
> I restarted SQL Server, did not resolve issue ( ie sysaltfiles still shows
> 2
> files) . I'm loathe to do a direct delete on master..sysaltfiles until I
> can
> discover if this kind of 'corruption' is not unknown... but do I have any
> other choice ?

Master, Tempdb, Msdb, Model?

I am looking for an opinion here...
What do most people do about these databases, leave the data & log file on the same drive
-or-
Move the log files to a separate drive?
I have the info on how to move the log files, and I do place my user database & logs on separate drives, but I am not sure of what a "best practice" is for the Sql system databases.
Any opinions are appreciated!
I would put the temp DB on a seperate drive as well
http://sqlservercode.blogspot.com/
"JLS" wrote:

> I am looking for an opinion here...
> What do most people do about these databases, leave the data & log file on the same drive
> -or-
> Move the log files to a separate drive?
> I have the info on how to move the log files, and I do place my user database & logs on separate drives, but I am not sure of what a "best practice" is for the Sql system databases.
> Any opinions are appreciated!
>
|||And also move the log file to a separate file
"JLS" wrote:

> I am looking for an opinion here...
> What do most people do about these databases, leave the data & log file on the same drive
> -or-
> Move the log files to a separate drive?
> I have the info on how to move the log files, and I do place my user database & logs on separate drives, but I am not sure of what a "best practice" is for the Sql system databases.
> Any opinions are appreciated!
>
|||I use to have data and log on same drive for system databases. The possible exception is tempdb.
This can be a high-activity database, so same reasoning goes for tempdb as for other databases.
Also, moving database files for system databases is a bit special, so read KB 224071.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"JLS" <jlshoop@.hotmail.com> wrote in message news:%23nzSw2PxFHA.2132@.TK2MSFTNGP15.phx.gbl...
I am looking for an opinion here...
What do most people do about these databases, leave the data & log file on the same drive
-or-
Move the log files to a separate drive?
I have the info on how to move the log files, and I do place my user database & logs on separate
drives, but I am not sure of what a "best practice" is for the Sql system databases.
Any opinions are appreciated!
|||Thanx everyone!
"JLS" <jlshoop@.hotmail.com> wrote in message news:%23nzSw2PxFHA.2132@.TK2MSFTNGP15.phx.gbl...
I am looking for an opinion here...
What do most people do about these databases, leave the data & log file on the same drive
-or-
Move the log files to a separate drive?
I have the info on how to move the log files, and I do place my user database & logs on separate drives, but I am not sure of what a "best practice" is for the Sql system databases.
Any opinions are appreciated!