Showing posts with label neebie. Show all posts
Showing posts with label neebie. Show all posts

Saturday, February 25, 2012

Neebie Q: .MDFs and SQL Server

I'm just starting out with VWD 2005...wow this product and language has come along way, but I have a couple of simple questions of confusion. It seems that Microsoft is really pushing SQL via SQL Express over Access...and depending on the answers to these questions below...it seems like it has been accomplished.

Q

1. When I create a .mdf via VWD 2005, why doesn't this database show up in SQL Server Management Express?

2. Are you able now to simple publish the .mdf and .ldf (/appdata) folder up to any webserver and be able to access that SQL database like you normally would an Access database via SQL express on the server? And, if this is the case, doesn't this imply that an ISP will be providing SQL support via the Express edition without even explicitly allowing SQL through their actual SQL database server?

3. Besides VWD2005, how can you manage the .mdf's within the web site?

I think you almost answered yourself because the MDF (Microsoft data file) and LDF ( log data file ) are not stored in the database they are stored in the data subfolder in Microsoft SQL Server folder in programs by the SQL Server engine not you the user. So you see you cannot manage the MDF in a web server, because SQL Server from version 7.0 uses ODS(on disk) file system. Now to the ISP question you need the full version of SQL Server the developer edition cost a few dollars, it is Enterprise edition with no deployment restrictions and ask the ISP to give you management studio access and you just back up and restore your database on their server. Hope this helps.|||

Thanks Caddre:

Yeh, I'm not totally understanding this. The VWD gives you a great interface to work on modifying an SQL database on the fly while writing code. How can you get an existing SQL database already in the SQL server proper into VWD so that you can add fields and manage tables on the fly from this interface as opposed to having another Enterprise Manager or SQL client window up to do that separately. Its confusing to me.

I don't understand how SQL server knows about this database yet doesn't know about it via the Management Studio and visa versa, why can't VWD see existing databases that Management Studio can see. I see Add Exsting Item in the VWD App_Data but it doesn't pull up the SQL Management Studio or anything to let me choose an existing database.

If a Connection String can find this database via just two files within a web folder locally, why wouldn't it be able to find it on a web server in the same fashion?

|||

You can do what you want in server explorer but I don't know if you have server explorer in VDW. The quick answer is people should not be allowed to move RDBMS (relational database management systems) file as local operating system file because you risk corrupting the database. Management studio is SQL Server and VWD is an IDE (integrated development environment). So it is a choice, use inproc session which is file system or do some extra work to use SQL Server as out of proc session. The difference is algebraically processed data in SQL Server or data that is just stored in the file system of the operation system.

If a Connection String can find this database via just two files within a web folder locally, why wouldn't it be able to find it on a web server in the same fashion?

That will take Microsoft's SQL Server the new kid on the block out of the RDBMS business for serious application.

Hope this helps.

|||

double post

|||

Let's see if I can answer a few of these:

1. Because the database isn't attached to the same instance of SQL Server Management Express at the time it's running.

2. Sort of, you can if it has SQL Express installed. No.

3. Depends on what you mean by "within the web site". You can attach the .mdf/.ldf files to a non-user instance of SQL Express (The one the management studio normally sees), then you can use management studio to do whatever you want. Just don't forget to unattach it so that when you are debugging or want to use it within VWD that it'll be able to instantiate a user instance of SQL Express, and attach the files correctly.

|||

How can I get an existing SQL database into the VWD environment?

Neebie needing help asap restoring sql

I am having problem which is getting worst by the moment. I had a power failure which my battery backup fail while running a large report in my SSRS all of a sudden I started getting reportservertempdb.dbo.persistedstream error. I could not get my reports to run through the iis webservice. I could get them to run from within my reportbuilder. I was told to reload my sql and restore it but I can not get my sql to successfully reinstall I am using the sql2005 dev ed. It either gives me a name instance issue or fails the database, report server and notifaction portion of the reload. I am not sure why it will not reload. any assistance would be great.

You dont have to reinstall SQL Server just for a power failure? Try restarting all the services - SQL server as well as IIS.

neebie Needed help with sql reports query

I am getting an error that says there is ann error near the union all This is the tsql query that I am tring to use in a sql report in my vs 2005 business int. can someone look at this query and tell me what is wrong with it.

SELECT
'Quarter 1' as 'qtr',
COUNT(JOB.JOBID) AS 'transcount',
COUNT(DISTINCT JOB.PATIENTID) AS 'patient count',
SUM(JOB.TRANSPORTATION_TCOST) AS 'tcost',
SUM(JOB.TRANSPORTATION_DISC_COST) AS 'dtcost',
AVG(JOB.TRANSPORTATION_DISC) AS 'avgTDisc',
SUM(JOB.TRANSPORTATION_TCOST) + SUM(JOB.TRANSPORTATION_DISC_COST) AS 'TGrossAmtBilled',
SUM(JOB.TRANSPORTATION_TCOST) / COUNT(DISTINCT JOB.PATIENTID) AS 'PatAvgT',
SUM(JOB.TRANSPORTATION_DISC) AS 'avgPercentDiscT',
SUM(JOB.TRANSPORTATION_TCOST) / COUNT(JOB.JOBID) AS 'RefAvgT',
JOB.JURISDICTION,
PAYER.PAY_COMPANY,
PAYER.PAY_CITY,
PAYER.PAY_STATE,
PAYER.PAY_SALES_STAFF_ID,
JOB.INVOICE_DATE,
INVOICE_AR.INVOICE_DATE AS Expr1,
INVOICE_AR.AMOUNT_DUE

FROM JOB
INNER JOIN INVOICE_AR
ON JOB.JOBID = INVOICE_AR.JOBID
LEFT OUTER JOIN PAYER
ON PAYER.PAYERID = JOB.PAYERID
LEFT OUTER JOIN STATES
ON JOB.JURISDICTION = STATES.INITIALS
WHERE
(INVOICE_AR.AMOUNT_DUE > 0)
AND
(INVOICE_AR.INVOICE_DATE BETWEEN @.startdate AND @.enddate)
AND
(MONTH(INVOICE_AR.INVOICE_DATE) in (1,2,3))

GROUP BY
JOB.JURISDICTION,
PAYER.PAY_COMPANY,
PAYER.PAY_CITY,
PAYER.PAY_STATE,
PAYER.PAY_SALES_STAFF_ID,
JOB.INVOICE_DATE,
INVOICE_AR.INVOICE_DATE, INVOICE_AR.AMOUNT_DUE
ORDER BY 'tcost' DESC

union all

SELECT
'Quarter 2' as 'qtr',
COUNT(JOB.JOBID) AS 'transcount',
COUNT(DISTINCT JOB.PATIENTID) AS 'patient count',
SUM(JOB.TRANSPORTATION_TCOST) AS 'tcost',
SUM(JOB.TRANSPORTATION_DISC_COST) AS 'dtcost',
AVG(JOB.TRANSPORTATION_DISC) AS 'avgTDisc',
SUM(JOB.TRANSPORTATION_TCOST) + SUM(JOB.TRANSPORTATION_DISC_COST) AS 'TGrossAmtBilled',
SUM(JOB.TRANSPORTATION_TCOST) / COUNT(DISTINCT JOB.PATIENTID) AS 'PatAvgT',
SUM(JOB.TRANSPORTATION_DISC) AS 'avgPercentDiscT',
SUM(JOB.TRANSPORTATION_TCOST) / COUNT(JOB.JOBID) AS 'RefAvgT',
JOB.JURISDICTION,
PAYER.PAY_COMPANY,
PAYER.PAY_CITY,
PAYER.PAY_STATE,
PAYER.PAY_SALES_STAFF_ID,
JOB.INVOICE_DATE,
INVOICE_AR.INVOICE_DATE AS Expr1,
INVOICE_AR.AMOUNT_DUE

FROM JOB
INNER JOIN INVOICE_AR
ON JOB.JOBID = INVOICE_AR.JOBID
LEFT OUTER JOIN PAYER
ON PAYER.PAYERID = JOB.PAYERID
LEFT OUTER JOIN STATES
ON JOB.JURISDICTION = STATES.INITIALS
WHERE
(INVOICE_AR.AMOUNT_DUE > 0)
AND
(INVOICE_AR.INVOICE_DATE BETWEEN @.startdate AND @.enddate)
AND
(MONTH(INVOICE_AR.INVOICE_DATE) in (4,5,6))

GROUP BY
JOB.JURISDICTION,
PAYER.PAY_COMPANY,
PAYER.PAY_CITY,
PAYER.PAY_STATE,
PAYER.PAY_SALES_STAFF_ID,
JOB.INVOICE_DATE,
INVOICE_AR.INVOICE_DATE, INVOICE_AR.AMOUNT_DUE
ORDER BY 'tcost' DESC

union all

SELECT
'Quarter 3' as 'qtr',
COUNT(JOB.JOBID) AS 'transcount',
COUNT(DISTINCT JOB.PATIENTID) AS 'patient count',
SUM(JOB.TRANSPORTATION_TCOST) AS 'tcost',
SUM(JOB.TRANSPORTATION_DISC_COST) AS 'dtcost',
AVG(JOB.TRANSPORTATION_DISC) AS 'avgTDisc',
SUM(JOB.TRANSPORTATION_TCOST) + SUM(JOB.TRANSPORTATION_DISC_COST) AS 'TGrossAmtBilled',
SUM(JOB.TRANSPORTATION_TCOST) / COUNT(DISTINCT JOB.PATIENTID) AS 'PatAvgT',
SUM(JOB.TRANSPORTATION_DISC) AS 'avgPercentDiscT',
SUM(JOB.TRANSPORTATION_TCOST) / COUNT(JOB.JOBID) AS 'RefAvgT',
JOB.JURISDICTION,
PAYER.PAY_COMPANY,
PAYER.PAY_CITY,
PAYER.PAY_STATE,
PAYER.PAY_SALES_STAFF_ID,
JOB.INVOICE_DATE,
INVOICE_AR.INVOICE_DATE AS Expr1,
INVOICE_AR.AMOUNT_DUE

FROM JOB
INNER JOIN INVOICE_AR
ON JOB.JOBID = INVOICE_AR.JOBID
LEFT OUTER JOIN PAYER
ON PAYER.PAYERID = JOB.PAYERID
LEFT OUTER JOIN STATES
ON JOB.JURISDICTION = STATES.INITIALS
WHERE
(INVOICE_AR.AMOUNT_DUE > 0)
AND
(INVOICE_AR.INVOICE_DATE BETWEEN @.startdate AND @.enddate)
AND
(MONTH(INVOICE_AR.INVOICE_DATE) in (7,8,9))

GROUP BY
JOB.JURISDICTION,
PAYER.PAY_COMPANY,
PAYER.PAY_CITY,
PAYER.PAY_STATE,
PAYER.PAY_SALES_STAFF_ID,
JOB.INVOICE_DATE,
INVOICE_AR.INVOICE_DATE, INVOICE_AR.AMOUNT_DUE
ORDER BY 'tcost' DESC

union all

SELECT
'Quarter 4' as 'qtr',
COUNT(JOB.JOBID) AS 'transcount',
COUNT(DISTINCT JOB.PATIENTID) AS 'patient count',
SUM(JOB.TRANSPORTATION_TCOST) AS 'tcost',
SUM(JOB.TRANSPORTATION_DISC_COST) AS 'dtcost',
AVG(JOB.TRANSPORTATION_DISC) AS 'avgTDisc',
SUM(JOB.TRANSPORTATION_TCOST) + SUM(JOB.TRANSPORTATION_DISC_COST) AS 'TGrossAmtBilled',
SUM(JOB.TRANSPORTATION_TCOST) / COUNT(DISTINCT JOB.PATIENTID) AS 'PatAvgT',
SUM(JOB.TRANSPORTATION_DISC) AS 'avgPercentDiscT',
SUM(JOB.TRANSPORTATION_TCOST) / COUNT(JOB.JOBID) AS 'RefAvgT',
JOB.JURISDICTION,
PAYER.PAY_COMPANY,
PAYER.PAY_CITY,
PAYER.PAY_STATE,
PAYER.PAY_SALES_STAFF_ID,
JOB.INVOICE_DATE,
INVOICE_AR.INVOICE_DATE AS Expr1,
INVOICE_AR.AMOUNT_DUE

FROM JOB
INNER JOIN INVOICE_AR
ON JOB.JOBID = INVOICE_AR.JOBID
LEFT OUTER JOIN PAYER
ON PAYER.PAYERID = JOB.PAYERID
LEFT OUTER JOIN STATES
ON JOB.JURISDICTION = STATES.INITIALS
WHERE
(INVOICE_AR.AMOUNT_DUE > 0)
AND
(INVOICE_AR.INVOICE_DATE BETWEEN @.startdate AND @.enddate)
AND
(MONTH(INVOICE_AR.INVOICE_DATE) in (10,11,12))

GROUP BY
JOB.JURISDICTION,
PAYER.PAY_COMPANY,
PAYER.PAY_CITY,
PAYER.PAY_STATE,
PAYER.PAY_SALES_STAFF_ID,
JOB.INVOICE_DATE,
INVOICE_AR.INVOICE_DATE, INVOICE_AR.AMOUNT_DUE
ORDER BY 'tcost' DESC

The ORDER BY clause should appear only once, at the very end. And I would not enclose column names in single quotes. And, you will likely need to ORDER BY 4 (that is, refer to the sorting column by position, not by the alias you are giving it).