|
This article may help.
Caveat - I use SQL Server not Access
I find it easier to lay out my own joins so they are more human readable. Start with the minimum tables to get the minimum result, then expand on it.
Get a list of material and their storage location with cost center
Get a list of wells and their cost centres
get the relationship between well and material, compare cost centers
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I liked the link- useful. Right on, I had started back with just two tables and worked my way up from there. I finally decided to add another ID field to one of the tables (breaking normalcy rules) but it helped make it an easier sql select statement. I only had to change a small bit of code to make sure that everything gets saved properly to the tables. So it works now- thanks.
Larry
|
|
|
|
|
lemarshall wrote: (breaking normalcy rules)
These should be known as guidlines as they are subject to reality and business requirement. Having said that I alway looks very closely at a design that does not conform to these guidelines, it is usually wrong somewhere.
You got it fixed - always satisfying.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hi,
i have created database with some fields containing nvarchar data. updated data in unicode kannda language text. I am writing queries like :- select * from table where district='UÀÄ®âUÁð'.It will not retriewing any rows. command executed success.
Thanks
************ S G KORE *******************
-- Modified Saturday, September 18, 2010 3:26 AM
|
|
|
|
|
try: select * from table where district=N'UÀÄ®âUÁð'
nvarchar and ntext types require the N prefix before the opening quote when you're searching for unicode text.
"An eye for an eye only ends up making the whole world blind"
|
|
|
|
|
Thank you Rob Smiley.
Its working
************ S G KORE *******************
|
|
|
|
|
Hey,
I have a table named volleyballsecondround8 which has columns like 'Winner', 'Loser' and 'MatchNo'.
I'd like to make a SELECT statement as it takes the 'Winner' where 'MatchNo'='M20' and puts it ind the [0]. row of my new table, then takes the 'Loser' of 'MatchNo'='M20' and puts it into the second row.
Therefore;
When I execute a query on volleyballsecondround8 like the following:
Select @row := @row + 1 as row,Winner,Loser
from volleyballsecondround8,(SELECT @row := 0) r
Where MatchNo IN('M20','M19','M18','M17') Order
I get e resultant table like:
ROW-Winner-Loser
----------------
1-India-Luxemburg
2-USA-Spain
3-Turkey-Argentina
Where, I want a table like:
ROW-TEAM
-----------
1-India
2-Luxemburg
3-USA
4-Spain
5-Turkey
6-Argentina
any help?
|
|
|
|
|
SELECT Row,
0 AS resultorder,
Winner
FROM volleyballsecondround8
UNION ALL
SELECT Row,
1,
Loser
FROM volleyballsecondround8
ORDER BY Row ASC, resultorder ASC
|
|
|
|
|
thanks for help but I decided to take all the data to a DataTable and then sort it in the C# part of the project, the hard way =)
thanks again
|
|
|
|
|
Simple question I know but I just cannot find a anything that works.
INSERT INTO [Location] ([id],[TZOffset],[Address],[Tel],[Fax],[Contact1],[Contact2],[Contact3],[Company],[Deleted],[Disabled]) VALUES (8,null,N'line1
line2
',N'',N'',1,2,3,null,null,null);
GO
I have tried everything I can find but there is no ESCAPE or CHAR function in SQLCE that I can find. You cannot use Stored Procedures, being CE so it has to be done in a command space.
If I store the CRLF in the raw data and push it using MFC then it works fine.
Any ideas?
Great isn't it. I can use SIN, COT, SQRT but I cannot put CRLF into a string!!?!??!?!
Alan
|
|
|
|
|
Me thinks your data structure is screwed, whenever I seelsomething like contact1, contact2, contact3 I know you are in deep poop. What if there is a fourth contact, woops lets add another column - FAIL
Create another table callemd contacts and a foreign key to this company table.
What has CRLF got to do with your insert statement?
There seems to be a number od problems with your insert statement. There is no comma between line1 and line2. Do comapny, deleted and disabled accept null as valid data.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Well you would be right if that is the way the fields were being used but they are not. There will only be three contacts as these fields hold pointers to entries in a Contact table.
I want to use a single ADDRESS field to store a multiline address rather than have 5 separate fields (one for each line).
There is no comma between line1 & line2 becuase they are stored as "line1\r\nline2 " in the application internals.
Now I can do that everywhere else (CString, Registry etc...) so why is it so unreasonable to want the same thing in SQL CE?
Alan
|
|
|
|
|
Not being a user of CE, and unwilling to install it in case it destabilises something, I can't test his. Have you tried forcing a linefeed manually by inserting chr(10). Then try chr(13) + chr(10), forcing a carriage return and line feed. Seems like your transport layer may be messing with the \r
Thanks for the explanation (one should stick to the Lounge when one returns home pissed) but I still think field1-3 is an incorrect design.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Ok things are getting even wierder than I thought they were to start with.
I have done some testing with my own code and I have observed that INSERT preserves the 0x000D,0x000A when written to the DB but then if I use UPDATE on the same field with the same data I get '?' stored in the DB?!?!?!?
Now this smells to me of a bug in the OLEDB... Anway it looks like I am going to have to restructure my code and DB to provide separate fields for each address line. I then have to glue them together when I retrieve them and split them apart when writing.
You are still getting hung up on the Contact1/2/3. This is simple the variable names I use within the code so I can easily find all the code dealing with the contacts. In presentation they are Primary, Secondary and Reserve. Simples.
Alan
|
|
|
|
|
Instead of multiple fields for the address you might look into storing it as XML data or varchar using XML to structure the address.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Dear experts,
Which version ODP.net is exactly required for oracle 11.2 and .net 2.0?
|
|
|
|
|
|
Hi,
Let me start off by giving some background on the events that have lead up to this issue that I'm having. I started with VS2008 and SQLEXPRESS. A few months later, I installed VS2010 and converted my project. A week or so later, I decided that I wanted to install SQL Server 2008 R2, so I installed that as well, not uninstalling SQLEXPRESS. My application has been running great and the reports were working fine for the past several months. I then rebuilt my entire application. Now I can not get my application to compile and I've been spinning my wheels in the mud for a week.
What I am seeing is the message in VS2010 that states: The report definition is not valid. Details: The report definition has an invalid target namespace 'http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition' which cannot be upgraded.
Not being a SQL Expert from an Admin side I have read a lot of forums which basically said that I needed to get the Report Server running and grant the roles accordingly. The Report Server now works and I can create reports using Report Server R3 no problem, however I'm still getting the error when trying to compile.
In the ReportViewer Tasks in VS2010, where you can select the report, I'm using a local report, not a server report. IE: ApplicationName.Reportname.rdlc
I am guessing the issue is the NameSpace is for a Server report and not a local report, and I should have some type of ConnectString? I really don't know what the problem is.
Any help is greatly appreciated.
*** UPDATE *** - I still have the issue with a brand new application built with VS2010 using the same table stored in SQL Server 2008 R2. Am I restricted to using Server Based reports after installing SQL Server 2008 R2?
<Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition">
<DataSources>
<DataSource Name="KTReunionDataSet">
<ConnectionProperties>
<DataProvider>System.Data.DataSet</DataProvider>
<ConnectString>/* Local Connection */</ConnectString>
</ConnectionProperties>
<rd:DataSourceID>0a8b6f23-4772-446f-9b27-5f180b760bc4</rd:DataSourceID>
</DataSource>
</DataSources>
Glenn
modified on Thursday, September 16, 2010 11:13 PM
|
|
|
|
|
hello,
i am usin sql server 2008.I have database which has been hosted on server i want to know whether they are given full access permission or not. bcoz when i work with local database it works fine. when i connect my server it will not works. like when i right click >> show top 1000 rows menu item will be displayed.it will not in when i connect to server. even i can't view tables listed in database.
|
|
|
|
|
You need to contact the hosting provider to ascertain whether or not you can have full access - although this sounds like the server instance is not properly set up to accept remote connections to the SQL instance.
|
|
|
|
|
Hello
Kindly tell me is it necessary to use
SET XACT_ABORT ON
in sql transaction or not?
Regards
|
|
|
|
|
try doing some reading [^] before jumping in. The second one seems to be interesting.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Basically, XACT_ABORT is a hint to SQL Server about the behaviour of a transaction if an error occurs. If XACT_ABORT is set to ON then the transaction will be rolled back. Now, why did I say it's a hint? The answer is because if XACT_ABORT is set to OFF, there's no guarantee that the transaction will roll back - it may or may not (depending on circumstances) choose to just roll back the statement that caused the error, allowing other parts to complete - or the entire transaction may be rolled back.
|
|
|
|
|
|
Here is code
<br />
SqlConnection connection = new SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename="D:\Working Directory\Win Application\Nakoda\Development\Bin\Database\cERP.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True");<br />
<br />
ServerConnection srvConn = new ServerConnection(connection);<br />
srvSql = new Server(srvConn);<br />
<br />
if (openBackupDialog.ShowDialog() == DialogResult.OK)<br />
{<br />
BackupDeviceItem bdi = default(BackupDeviceItem);<br />
bdi = new BackupDeviceItem(openBackupDialog.FileName, DeviceType.File);<br />
<br />
BackupDeviceItem bdid = default(BackupDeviceItem);<br />
bdid = new BackupDeviceItem(openBackupDialog.FileName, DeviceType.File);<br />
<br />
string db = cmbDatabase.SelectedItem.ToString();<br />
<br />
Restore rs = default(Restore);<br />
rs = new Restore();<br />
rs.NoRecovery = true;<br />
rs.Devices.Add(bdi);<br />
rs.Database = db;<br />
rs.SqlRestore(srvSql);<br />
<br />
<br />
I Got Exception
Microsoft.SqlServer.Management.Smo.FailedOperationException occurred
HelpLink=http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1447.4+((KJ_RTM).100213-0103+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Restore+Server&LinkId=20476
Message=Restore failed for Server '\\.\pipe\1FF7F0B1-18D8-42\tsql\query'.
Source=Microsoft.SqlServer.SmoExtended
Operation=Restore
StackTrace:
at Microsoft.SqlServer.Management.Smo.Restore.SqlRestore(Server srv)
at DatabaseBackup.SQL_Backup_Restore.btnRestore_Click(Object sender, EventArgs e) in D:\Working Directory\Win Application\Nakoda\Development\Source\DatabaseBackup\MSSQLBackupRestore.cs:line 186
InnerException: Microsoft.SqlServer.Management.Common.ExecutionFailureException
Message=An exception occurred while executing a Transact-SQL statement or batch.
Source=Microsoft.SqlServer.ConnectionInfo
StackTrace:
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(StringCollection sqlCommands, ExecutionTypes executionType)
at Microsoft.SqlServer.Management.Smo.ExecutionManager.ExecuteNonQuery(StringCollection queries)
at Microsoft.SqlServer.Management.Smo.BackupRestoreBase.ExecuteSql(Server server, StringCollection queries)
at Microsoft.SqlServer.Management.Smo.Restore.SqlRestore(Server srv)
InnerException: System.Data.SqlClient.SqlException
Message=RESTORE cannot process database 'D:\WORKING DIRECTORY\WIN APPLICATION\NAKODA\DEVELOPMENT\BIN\DATABASE\CERP.MDF' because it is in use by this session. It is recommended that the master database be used when performing this operation.
RESTORE DATABASE is terminating abnormally.
Source=.Net SqlClient Data Provider
ErrorCode=-2146232060
Class=16
LineNumber=1
Number=3102
Procedure=""
Server=\\.\pipe\1FF7F0B1-18D8-42\tsql\query
State=1
StackTrace:
at Microsoft.SqlServer.Management.Common.ConnectionManager.ExecuteTSql(ExecuteTSqlAction action, Object execObject, DataSet fillDataSet, Boolean catchException)
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)
InnerException:
|
|
|
|