|
Hi,
Another approach to this is to use correlated scalar queries. Grouping would be usable here but by using scalars, it may be easier to read and modify. For example:
SELECT CustomerName,
(SELECT MIN(TransTimeStamp) FROM CustomerLog cl WHERE cl.CustomerID = c.CustomerID) AS StartTime,
(SELECT MAX(TransTimeStamp) FROM CustomerLog cl WHERE cl.CustomerID = c.CustomerID) AS EndTime
FROM Customer c
If you want to find corresponding pairs you could use something like this:
SELECT CustomerName,
(SELECT MIN(TransTimeStamp) --min to find first stop after each start
FROM CustomerLog cl2
WHERE cl2.CustomerID = c.CustomerID
AND cl2.Status = 3
AND cl2.TransTimeStamp > cl.TransTimeStamp) AS EndTime
FROM Customer c,
CustomerLog --starts
WHERE cl.CustomerID = c.CustomerID
AND cl.Status = 2
There may be several typos in this but you get the idea.
Mika
|
|
|
|
|
I've been having trouble when trying to add a User Instance SQL database to a Visual Studio 2008 solution. The error is shown in this[^] image.
Connections to SQL Server files (*.mdf) require SQL Server Express 2005 to function properly. Please verify the installation of the component of download from the URL: http:
Note that SQL Server works quite happily as long as it's not a user instance.
Does anybody have any ideas on how to solve this problem?
I doubt it. If it isn't intuitive then we need to fix it. - Chris Maunder
|
|
|
|
|
Hi,
Never seen this, but few questions:
- is SQL Browser running
- can you connect using Server Explorer
Mika
|
|
|
|
|
Mika Wendelius wrote: is SQL Browser running
Yes
Mika Wendelius wrote: can you connect using Server Explorer
If it's not a user instance then yes. I.e. if I set it up in SQL Management Studio and connect like a "full" server then everything works.
|
|
|
|
|
Okay, by Server Explorer I actually meant Visual Studio Server Explorer.
I would believe that the problem is in user instance behaviour. Since it does not use the default port (1433) and the instance name usually must be specified, there's a problem in acquiring this info in VS. Also if I remember correctly, user instances must be explicitely allowed during installation but in this case I believe you have done that.
I'll try to install named instance and test this but it will take some time. Meanwhile could you test that if you have an active connection in VS Server Explorer, is the behaviour different or can you create the database to VS project from Server Explorer (never used server explorer this way so it may be a dumb suggestion)
Mika
|
|
|
|
|
Mika Wendelius wrote: Okay, by Server Explorer I actually meant Visual Studio Server Explorer.
This is exactly the same message regardless of anything inside Visual Studio. My guess is that although I'm running the x64 edition of SQL Server it's only got the "bindings" for an x86 version.
Mika Wendelius wrote: Also if I remember correctly, user instances must be explicitely allowed during installation but in this case I believe you have done that.
Done that.
Mika Wendelius wrote: Meanwhile could you test that if you have an active connection in VS Server Explorer
I have an active connection in Server Explorer to the "proper" SQL database. If I detach that database and then point Server Explorer at the database file rather than the connection then the same message pops up.
Mika Wendelius wrote: is the behaviour different or can you create the database to VS project from Server Explorer (never used server explorer this way so it may be a dumb suggestion
You can and I think the method is the same whether you create it through Server Explorer or Add New Item. Add New Item will automatically add a connection to the database to Server Explorer.
One thing I haven't tried recently is installing the x86 version of SQL Server (I can uninstall or reinstall SQL quite happily but don't particularly fancy uninstalling VS2008).
Mika Wendelius wrote: I'll try to install named instance and test this but it will take some time
I've got a trial install of Vista x64 Ultimate inside a VMWare virtual machine if you'd like a copy for testing (will take quite a while since even compressed as hard as it'll go it's over 4GB).
|
|
|
|
|
Mika Wendelius wrote: Okay, by Server Explorer I actually meant Visual Studio Server Explorer.
This is exactly the same message regardless of anything inside Visual Studio. My guess is that although I'm running the x64 edition of SQL Server it's only got the "bindings" for an x86 version.
Mika Wendelius wrote: Also if I remember correctly, user instances must be explicitely allowed during installation but in this case I believe you have done that.
Done that.
Mika Wendelius wrote: Meanwhile could you test that if you have an active connection in VS Server Explorer
I have an active connection in Server Explorer to the "proper" SQL database. If I detach that database and then point Server Explorer at the database file rather than the connection then the same message pops up.
Mika Wendelius wrote: is the behaviour different or can you create the database to VS project from Server Explorer (never used server explorer this way so it may be a dumb suggestion
You can and I think the method is the same whether you create it through Server Explorer or Add New Item. Add New Item will automatically add a connection to the database to Server Explorer.
One thing I haven't tried recently is installing the x86 version of SQL Server (I can uninstall or reinstall SQL quite happily but don't particularly fancy uninstalling VS2008).
Mika Wendelius wrote: I'll try to install named instance and test this but it will take some time
I've got a trial install of Vista x64 Ultimate inside a VMWare virtual machine if you'd like a copy for testing (will take quite a while since even compressed as hard as it'll go it's over 4GB).
[edit]
In the meantime I've set up an XP virtual machine to use for all this work anyway and it feels "fun" to go back to such a retro OS (although I have installed an add-on which gives me the Vista Start Menu).
It'd just be nice to have this thing up and running on an x64 machine since everything else works perfectly. Maybe it's time for a re-install .
[/edit]
|
|
|
|
|
Hi again,
I installed another instance (with such an original name as Test ) After that I tried to add a new item and then in the dialog box from data node "Service-based Database". This failed with an error mesagge saying that the conection cannot be established because the server cannot be found. This is quite obvious since there's no dialog box asking where do I want to connect and the second instance is not listening on default ports and so on.
What I'm currently wondering is that the error I get is different from yours. Am I doing this differently?
Mika
|
|
|
|
|
I did some tests on the service-based database. When adding it to the project it actually starts SQL Server in desktop session. So the database is not added to service controlled sql server at that time. This didn't make any sense since one of the startup parameters is instance name. How can Visual Studio start the instance without knowing relevant parameters . Then I found this:
http://msdn.microsoft.com/en-us/library/ms345154.aspx#sseover_topic18[^]
Visual Studio Integration
SQL Server Express is installed with all editions of Visual Studio. Visual Studio installs SQL Server Express using the instance name SQLEXPRESS. In SQL Server Express, the applications rely on the SQLEXPRESS instance name. The goal of Visual Studio and SQL Server Express integration is to make database access with SQL Server Express as simple and easy as working with Jet. This is true not only for client applications but also for ASP.NET Web server scenarios.
This makes me wonder if there actually is any way to use non-default instances with Visual Studio...
Mika
|
|
|
|
|
Hmm, I'll try installing an instance named SQLExpress and see what happens. With regards to the error message it's a different one I think, it simply refuses to try and connect.
BTW, thanks for all the help that you're providing me with
|
|
|
|
|
Renaming the instance to SQLExpress fixes it. What a situation!
Thanks for your help and the research, I definitely owe you a
|
|
|
|
|
You're welcome
In the meantime I investigated the templates for new items under Visual Studio ItemTemplates, but I didn't find any way to define a new template against another instance name nor to change the default name of the instance to connect to. Seems that they have hardcoded this into VS. Nice...
Mika
|
|
|
|
|
Mika Wendelius wrote: Seems that they have hardcoded this into VS. Nice...
Perhaps it's because only the express edition supports user instances? Maybe they just haven't got around to refactoring it out
|
|
|
|
|
Hi All
I'm new to SQL reporting services and have bought a book on it but can't seem to find out how to do pagination on my reports.
Can anyone help?
Thanks in advance
"Sex is not the answer, it's the question and the answer is yes"
|
|
|
|
|
Is the pagination not a function of how your report is displayed - e.g. it will be differnt in a web page than in an excel file. I think the report manager (in 2005 anyway) handles it's own pagination.
|
|
|
|
|
I just want the report to display the page number in the footer but can't find how to do this?
"Sex is not the answer, it's the question and the answer is yes"
|
|
|
|
|
Hi,
- add a Textbox from toolbox
- right click on textbox
- select Expression...
- add formula to expression =Globals!PageNumber
Hope this helps,
MIka
|
|
|
|
|
Thanks, it worked perfectly! Just inquisitive to know now. Is there a way to say something like
"Page 1 of 10" instead of just the page number?
"Sex is not the answer, it's the question and the answer is yes"
|
|
|
|
|
|
Great, Thanks for the help. I really appreciate it.
Cheers
"Sex is not the answer, it's the question and the answer is yes"
|
|
|
|
|
You're welcome
Mika
|
|
|
|
|
How can I a make a bulk insert in Oracle from a csv file... like the "Bulk insert" statement in SQL server ..pls help me..
|
|
|
|
|
Hi,
SQL*Loader can be used for inserting data from a file to database. It's not a command like in SQL Server but an utility.
Hope this helps,
Mika
|
|
|
|
|
O.k, I'm re-wording my post.
How can I dynamically change the target database of some SQL code like a stored procedure or a function?
In other words...
I have this:
Execute MyDataBase..procAddHistoryEvent(@Blah,etc)
Update MyDataBase..tblWoof set WoofColumn1 = 'bark952' where WoofColumn2 = @Blah
but my solution requires something like this:
Execute @SelectedDB..procAddHistoryEvent(@Blah,etc)
Update @SelectedDB..tblWoof set WoofColumn1 = 'bark952' where WoofColumn2 = @Blah
My old post_________________________________________________________________________________________
Scenario...
Our system runs multiple DB's on a single SQL2005 Server. The DB naming is usually is not a problem since our software can be configured to which DB it should connect for which data. I.e Client1's application could connect to the DB Client1Data.
So when we restore data for debugging and don't want to overwrite an existing DB we simply restore it as (e.g.) Client1DataTest.
But...
Our software uses multiple DB's, so Client1's software also uses DB's for (e.g.) Client1Messages, Client1Mail etc. So for debugging we would load DB's for Client1DataTest, Client1MessagesTest, Client1MailTest etc.
So my question...
All our DB's run stored procedures (SP's) and in quite a few cases one DB will execute a SP on another DB with the following syntax:
Execute Client1Data..procAddHistoryEvent(@Blah,etc)
or simply select, update, delete and insert data on another DB e.g.:
Update Client1Messages..tblWoof set WoofColumn1 = 'bark952' where WoofColumn2 = @Blah
It's clear how the above is kinda hardcoded.
So when we run our system on a test DB say, Client1DataTest, it still wrongly accesses data from and executes code on Client1Messages instead of Client1MessagesTest.
Is there a better way of doing this OTHER than compiling and executing SQL strings all over the place?
Kind Regards
modified on Thursday, August 14, 2008 9:03 AM
|
|
|
|
|
Hi,
Synonyms are the helpfull for this
Mika
|
|
|
|