|
Hi, I have simple table1 like this:
name type value
-----------------------
aa A 0.1
aa B 0.2
aa C 0.3
bb A 0.4
bb B 0.5
bb C 0.6
Then, I doing the code from Krish
SELECT nama,
CASE WHEN test_type = 'A' THEN value ELSE 0 END AS 'A',
CASE WHEN test_type = 'B' THEN value ELSE 0 END AS 'B',
CASE WHEN test_type = 'C' THEN value ELSE 0 END AS 'C'
FROM table1
But the result is:
name A B C
--------------------------
aa 0.1 0 0
aa 0 0.2 0
aa 0 0 0.3
bb 0.4 0 0
bb 0 0.5 0
bb 0 0 0.6
But, I'm expecting table like this:
name A B C
--------------------------
aa 0.1 0.2 0.3
bb 0.4 0.5 0.6
Thanks a lot !!!
|
|
|
|
|
Hi, I have simple table1 like this:
name type value
------------------
aa A 0.1
aa B 0.2
aa C 0.3
bb A 0.4
bb B 0.5
bb C 0.6
Then, I doing the code from Krish
SELECT nama,
CASE WHEN type = 'A' THEN value ELSE 0 END AS 'A',
CASE WHEN type = 'B' THEN value ELSE 0 END AS 'B',
CASE WHEN type = 'C' THEN value ELSE 0 END AS 'C'
FROM table1
But the result is:
name A B C
-------------------
aa 0.1 0 0
aa 0 0.2 0
aa 0 0 0.3
bb 0.4 0 0
bb 0 0.5 0
bb 0 0 0.6
But, I'm expecting table like this:
name A B C
-------------------
aa 0.1 0.2 0.3
bb 0.4 0.5 0.6
How a resolve this problem, need your help.
Thanks a lot !!!
|
|
|
|
|
A client sent me a backup copy of his database so that I could debug a stored procedure.
After I restored the .bak file into my copy of SQL Server 2005, I see that it renamed every table by prepending the original name of the database to each table name.
So now every table must be referred to by "schema.tablename" instead of just "tablename". This breaks every stored procedure in the database because they all still refer to the tables by their old names.
Why does it insist on renaming the tables, and how do I get it to stop doing that whenever I restore a database from a .bak file?
--------------------------------
"All that is necessary for the forces of evil to win in the world is for enough good men to do nothing" -- Edmund Burke
|
|
|
|
|
I've never seen it do that before ... I've always restored databases back to databases with the same name and it works fine.
|
|
|
|
|
I am in the proccess of writing a small membership program and all the info is being stored in an MS Access database. I've gotten stumped on coding the datagridview's "DataRelation" object because I'm having to code through three table levels.
To explain, I want to create families (Father, Mother, Children) and link them through the DataGridview.
I have a master table called "tblFamilyNames" that holds the "primary key" and anniversary date. I then have a table called tblFamilyDetails. It links the family(Father, Mother, Children) together by storing the primary key value from tblFamilyNames in a column called "intFamilyID".
In tblFamilyDetails, there is a column: "intMemberID" that points to a record in the third table: tblMembers".
My question is, how do I bind the first table: "tblFamilyDetails" with the third table: "tblMembers" so that the user can see the member's info without seeing the intermediate table: "tblFamilyDetails"?
may your code be error free
|
|
|
|
|
This may not be the answer that you're expecting, but have you considered using Views to de-normalize the data? It sounds like you could create a "Family" view that is an INNER JOIN of tblFamilyNames and tblFamilyDetails. This could then be JOINed to tblMembers to give you a single unified view of the data.
Cheers!
Humble Programmer
,,,^..^,,,
|
|
|
|
|
Hi
I have a problem with INSERT,UPDATE table when working with ODBC in DotNet.
if you go to the following link and fill all the field and then click button see the error .i can not solve this.
http://www.bastanbar.com/ViewOrders.aspx
my connection string is in the following function
<br />
Public Shared Function GetConnection() As OdbcConnection<br />
Dim myConn As OdbcConnection<br />
Dim connStr, path As String<br />
Dim Request As System.Web.HttpRequest<br />
path = HttpContext.Current.Request.PhysicalApplicationPath()<br />
path = path + "data.mdb"<br />
connStr = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" + path + ";ReadOnly=0;"<br />
myConn = New OdbcConnection(connStr)<br />
Return myConn<br />
End Function<br />
when i try to add one record to my table an error ocures
"ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query"
please help me to solve this problem
|
|
|
|
|
What does your INSERT query look like?
|
|
|
|
|
Hi martin
My INSERT query is in the following function
<br />
Public Function SaveTransInfo(ByVal idrequestman As Long, ByVal iddestinationInfo As Long, ByVal Y As String, ByVal M As String, ByVal D As String, ByVal Goods As String, ByVal idworker As Byte, ByVal Tonaj As Double, ByVal place As String, ByVal sdate As String) As Boolean<br />
Dim sqlStr As String<br />
Dim myCon As OdbcConnection = GetConnection()<br />
sqlStr = "INSERT INTO TransInfo(idrequestman,iddestinationInfo,Y,M,D,Goods,idworker,Tonaj,place,sdate) VALUES(" + idrequestman.ToString & "," & iddestinationInfo & ",'" & Y & "','" & M & "','" & D & "','" & Goods & "'," & idworker.ToString & "," & Tonaj.ToString & ",'" & place & "','" & sdate & "');"<br />
Try<br />
Dim myCommand As New OdbcCommand(sqlStr, myCon)<br />
myCon.Open()<br />
myCommand.ExecuteNonQuery()<br />
Catch ex As Exception<br />
myCon.Close()<br />
HttpContext.Current.Response.Write(ex.Message)<br />
Return False<br />
End Try<br />
myCon.Close()<br />
Return True<br />
End Function<br />
<br />
thanks for your attention<br />
<br />
|
|
|
|
|
You may need to adjust the permissions on the database file so that it can be written to by the ASP.Net user.
In Explorer navigate to the file and go to it's properties. Select security and add the built in ASPNET user and give it read/write permissions.
|
|
|
|
|
Hi
My files in my Host and i check read/write permissions .i have read/write permission to my db and the folder that my db reside in.(in fireFTP of mozilla i right click on my db and click property in the opend widow show me that i have read/write permissions to db)
i set
<br />
authentication mode="Windows" <br />
identity impersonate="true" <br />
BestRegards
|
|
|
|
|
Hmmm... I'm not sure what the cause is really. If you hard code the entire SQL statement (just for testing problems, does the error still occur?
I've also found this, which might be useful:
http://support.microsoft.com/kb/175168[^]
|
|
|
|
|
HI
Thanks for your help.i visit your link but in .NET i can't find any property or method like that.
again i try to solve this problem.
thank you
|
|
|
|
|
i try to attach a database to sqlserver 2005 in my computer
when click attach i see a exception with this message :
TITLE: Microsoft SQL Server Management Studio
------------------------------
Attach database failed for Server 'SHOKRIAN'. (Microsoft.SqlServer.Smo)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.1399.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attach+database+Server&LinkId=20476
------------------------------
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
Could not find row in sysindexes for database ID 9, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.
Could not open new database 'ProposalSystem'. CREATE DATABASE is aborted. (Microsoft SQL Server, Error: 602)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=602&LinkId=20476
------------------------------
BUTTONS:
OK
------------------------------
help to silv this problem plz
|
|
|
|
|
Do you have a typo? It looks like either the ProposalSystem database doesn't exist or it has some problems with it. Did you delete some system tables from this database?
Ben
|
|
|
|
|
I'm using SQL Server 2005 and when trying to create an Agent Job I get the following error:
Unable to cast object of type 'Microsoft.SqlServer.Management.Smo.SimpleObjectKey' to type 'Microsoft.SqlServer.Management.Smo.Agent.JobObjectKey'. (Microsoft.SqlServer.Smo)<br />
I've googled it but the only solution provided was to repair the SQL Native Client, which didn't solve my problem.
Any ideas what else should I try?
Cheers,
Mircea
"Pay people peanuts and you get monkeys" - David Ogilvy
|
|
|
|
|
Hi all,
Few days back an interviwer asked me an SQL question. I searched the answer in the net, but i cant able to find it. Plz any one help me. The question is"How and where will you store the records retrived from an table temporarily in the database", he asked me without creating an table, how to store the records retrived (using select query) from an table to temporavery table, actually there is no such an table, in other word that temporavery table is an virtual table.
Can any one suggest me the answer plz.
Thanks in advance
Know is Drop, Unknown is Ocean
|
|
|
|
|
|
You can create a temporary table by prefixing the name with # which which create a table for that user in the TempDb database on the SQL server, meaning that each user will have their own copy
You can also do global temporary tables as well if you need to.
Read more about this here[^]
|
|
|
|
|
|
Hi,
I'm trying to write a small application in VB6 to backup and restore databases. I have looked up the code in the SQL Server Books Online but it keeps on giving me an SQL error.
I have tried 2 different forms of code ... see below with the error.
1)
SQL
USE master
EXEC sp_addumpdevice 'disk', 'APDB', DISK ='C:\SQLBCKUTIL\DatabaseBackups\05Jul2007_101009_APDB.dat', 2
ERROR
Incorrect syntax near the keyword 'DISK'.
2)
SQL
BACKUP DATABASE APDB
TO DISK = 'C:\SQLBCKUTIL\DatabaseBackups\05Jul2007_101009_APDB.BAK'
WITH FORMAT,
NAME = 'Full Backup of APDB'
ERROR
Cannot open backup device 'C:\SQLBCKUTIL\DatabaseBackups\05Jul2007_101009_APCON.BAK'. Device error or device off-line. See the SQL Server error log for more details.
BACKUP DATABASE is terminating abnormally.
Anyone have any ideas?
Cheers for now,
Allan
PEBKAC
Problem Exists Between Keyboard And Chair
|
|
|
|
|
Have you found a solution to your problem?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
unfortunately not.
any suggestions????
Cheers for now,
Allan
PEBKAC
Problem Exists Between Keyboard And Chair
|
|
|
|
|
|
Hi,
can anyone tell me how to genrate sdf files in sql 7.0.
I had search this in google but i havent got proper answer.
So,can anyone help me in this.
Thanks.
GIRISH
|
|
|
|