Need query to get below output.Kindly help
output of query
I have tried it but unable to get it.
Thanks,
Amar
Related
I often use RODBC to work with MS Access files in R. For removing existing tables sqlDrop works fine, e.g.:
db <- odbcConnectAccess(choose.files(caption="select database"))
sqlDrop(db, "existing_dummy_table")
What I need to do now is to delete an existing query that is stored in the Access database. sqlDrop does only seem to work with tables, not with querys.
sqlDrop(db, "existing_dummy_query")
brings up:
Error in odbcTableExists(channel, sqtable, abort = errors) :
‘existing_dummy_query’: table not found on channel
Is there any solution how to delete/remove existing queries?
Thank you!
After a lot of testing I found a soultion myself:
sqlQuery(db, "DROP TABLE existing_dummy_query";)
Maybe its helpful for others. DROP VIEW did not work. I don't know why.
I am using sql server database in R. And trying to build a data frame with col1, col2. But while raise a query for list of fields in table "VisitDetails" it throwing error.
dbListFields(con, VisitDetails)
Can anyone tell me why I am not able to list the fields of table?
Where did I wrong for the above syntax?
"con" is the connection to sql server with login.
Thanks in advance.
I tried with dbListFields(con, "VisitDetails").
It works.
I wonder if there is query length limitation for sqlQuery function from RODBC package? I can't find any information in documentation but that's my hypothesis.
The thing is that when I use Hive editor to write a query I get correct output for my queries (including the long one). But when I connect through the sqlQuery() the long query (~250) doesn't work. I get error:
[RODBC] ERROR: Could not SQLExecDirect 'my long query here'
I can't think about different reason why the query works in Hive editor and does not work with sqlQuery().
I know 250 lines is a lot for SQL query but unfortunately I don't have permission to create temporary table in database I work with, so I do it in my code and that's why the code is so long. There's no way I can shorten the code.
Any help appreciated.
I am getting this error while saving my data into the table. I have already created a 'product_Design' table in my database. I am using Sql Server 2008. Everything is working fine on local host but not on the server. I also tried to insert data in different tables and its working but I am just not able to insert data in this(product_Design) table ? I really need help regarding this thing.
here is my sql query
insert into z3ctjholo.dbo.product_Design values(#prodID, #productName, #designName, #designPath, #finalDesign, #front, #cont, #divHeight, GETDATE(), 0, 1)
I also tried this query
insert into product_Design values(#prodID, #productName, #designName, #designPath, #finalDesign, #front, #cont, #divHeight, GETDATE(), 0, 1)
Both the queries are generating error. Please help me out.
Thanks..
So finally i found what is the problem. if you ever face such kind of problem then execute this command in sql server and see whether your table is connected to any schema apart from dbo. Use this statement to check whether the table is connected to any other schema.
use yourDatabaseName
Then
SELECT * FROM INFORMATION_SCHEMA.TABLES
after that if you find that your table is connected with other schema apart from dbo then use your any statement like this
select * from schemaName.tableName
(eg. my schema name is z3ctjholo and my table name is product_Design)
so my statement would be like this
select * from z3ctjholo.product_Design
what i was doing wrong, i was using two schema names (z3ctjholo.dbo.product_Design).
I hope it will help someone..
Thanks...
There are two reasons, I can find so far.
1. Either the connection settings in web.config is incorrect.
2. your database is case sensitive collation and so check the name with case. May be you have created the table with name Product_Design and trying to insert in product_Design, in this case also, the command may not work.
Please check both the points.
I'm trying to get a single value from my table in a database. They are all given a unique id when stored. Here is the code I use to put the in:
With SqlDataSource1
.InsertParameters("page").DefaultValue = ViewState("TrueURL")
If My.User.IsAuthenticated Then
.InsertParameters("sender").DefaultValue = My.User.Name
Else
.InsertParameters("sender").DefaultValue = Request.UserHostAddress.ToString
End If
.InsertParameters("details").DefaultValue = PrepareText(TextBox2.Text)
.InsertParameters("date").DefaultValue = Now()
.Insert()
End With
That was so you could get an idea of what I was looking for, I'm not looking for sql statements, I don't know how to use them.
Just keep in mind, this is all vb.net/asp.net.
Thanks!
--EDIT--
I think I found something useful but I can't find how to use it. The Select function. It returns something and accepts parameters like the insert one I mentioned above... any ideas?
You cant extract it without first running an SQL query to extract it.
If you've got this far, read a little further in the MS help pages about how to run the select querys, this is where you would put your SQL statements.