I am new to schema, roles and user management part in sql server. Till now I used to work with simple dbo schema but now after reading few articles I am intrested in creating schema for managing my tables in a folder fashion.
At present, I want to create a schema where i want to keep my tables that have same kind of functionality. When ...
Which is the most simple way to create code ( with PHP and SQL ) which will count the file downloads ?
I already have an integer column in the base dedicated for this feature...
( link to some example will also be welcomed )
...
Can I do WHERE operations on a calculated date field?
I have a lookup field, which has been written badly in SQL and unfortunately I can't change it. But basically it stores dates as characters such as "July-2010" or "June-2009" (along with other non date data). I want to extract the dates first (which I did using a LIKE opertor) and th...
I need to write an SQL script that selects one record in table1, then does a lookup in the remaining tables in the database. If it doesn't find the record, I need delete the record from table1. Anyone provide some sample script?
...
I am running two very similar update queries but for a reason unknown to me they are using completely different execution plans. Normally this wouldn't be a problem but they are both updating exactly the same amount of rows but one is using an execution plan that is far inferior to the other, 4 secs vs 2 mins, when scaled up this is cau...
Hi,
Consider the following structure :
Ignore the table user_token.
Now, imagine that you need to get all the roles related to an user, wich may be through it's related groups or directly related to him. In case the same role appears related to a group and the user directly, the role related to the user will prevail over the role gi...
I have many controls on my aspx page (DropDownLists) each bound to a SQLDataSource.
They stored proc takes a long time to run. I have been working with the DBAs for weeks to try to speed them up. We got it down to about 1-2 seconds for the slowest ones. However loading eight of these one a page is too long for a user to wait!
So, I wou...
I am writing a trigger to audit updates and deletes in tables. I am using SQL Server 2008
My questions are,
Is there a way to find out what action is being taken on a record without going through the selection phase of the deleted and inserted tables?
Another question is, if the record is being deleted, how do I record within the au...
is there a way to clear an entire column in a datasheet in access? i can just right click on it and delete it but that will affect the structure, i just need to clear all the records. how do i do this?
perhaps the question i should be asking is how do i clear the entire contents of a datasheet in access?
...
So I am trying to emulate google app's status page: http://www.google.com/appsstatus#hl=en but for backups for our own servers. Instead of service names on the left it'll be server names but the dates and hopefully the pagination will be there too. My models look incredibly similar to this:
from django.db import models
STATUS_CHOICES...
DoCmd.TransferText acImportDelim, Import-Accounts, "tableImport", _
"C:\Documents and Settings\accounts.txt", True
The second parameter: Import-Accounts is the actual name of the saved import specifications. supposedly it does NOT need to be in quotes; however in this case since there is a - there it is treating it as if i were doi...
in access i am doing this:
insert into accounts_changes
(select *
from accounts
where [Agency Code]
in (select * from tableimport))
it says that it doesnt like this INSERT statement
update:
sSql = "insert into accounts_changes (select * from Accounts where [Agency Code] in (select [Agency Code] from tableimport))"
i did...
rowsUpdated is an int32 to count how many rows are updated
rowsToUpdate = dataset.ParentTable.Select("", "", dataviewRowState.Added)
if rowsToUpdate isNot Nothing then
for each row as datarow in RowsToUpdate
**changes the rowstate:**
rowsUpdated = rowsUpdated + ParentTableAdapter.update(row)
Next row
End if
I'm sure it'...
I'm running a case-insensitive search on a table with 7.2 million rows, and I was wondering if there was any way to make this query any faster?
Currently, it takes approx 11.6 seconds to execute, with just one search parameter, and I'm worried that as soon as I add more than one, this query will become massively slow.
SELECT count(*)
...
Tried my usual references at w3schools and google. No luck
I'm trying to produce the following results. QTY is a derived column
| Position | QTY
--------------------
1 Clerk 2
2 Mgr 2
Here's what I'm not having luck with:
SELECT Position, Count(position) AS 'QTY'
FROM tblemployee
Where ('QTY' != 1)
...
I have a fairly simple query I'm try to write.
If I run the following query:
SELECT parts.id, parts.type_id
FROM parts
WHERE parts.type_id=1
OR parts.type_id=2
OR parts.type_id=4
ORDER BY parts.type_id;
I get all the rows I expect to be returned. Now when I try to grab the parent_unit from another table with the following qu...
Approach #1:
DECLARE @count int
SET @count = 2000
DECLARE @rowcount int
SET @rowcount = @count
WHILE @rowcount = @count BEGIN
DELETE TOP (@count) FROM ProductOrderInfo
WHERE ProductId = @product_id
AND bCopied = 1 AND FileNameCRC = @localNameCrc
SELECT @rowcount = @@ROWCOUNT
WAITFOR DELAY '000:00:00.400'
Approach #2:
DECLARE @c...
The following query takes about 1 minute to run, and has the following IO statistics:
SELECT T.RGN, T.CD, T.FUND_CD, T.TRDT, SUM(T2.UNITS) AS TotalUnits
FROM dbo.TRANS AS T
JOIN dbo.TRANS AS T2 ON T2.RGN=T.RGN AND T2.CD=T.CD AND T2.FUND_CD=T.FUND_CD AND T2.TRDT<=T.TRDT
JOIN TASK_REQUESTS AS T3 ON T3.CD=T.CD AND T3.RGN=T.RGN AND T3.TASK ...
;with Ranked(Empid,Mngrid,Empnm,RN,level) As
(select Empid,Mngrid ,Empnm ,row_number() over (order by Empid)AS RN ,
0 as level from dbo.EmpMngr),
AnchorRanked(Empid,Mngrid,Empnm,RN,level)
AS(select Empid,Mngrid,Empnm,RN ,level from Ranked ),
RecurRanked(Empid,Mngrid,Empnm,RN,level)
AS(select Empid,Mn...
I'm using sqlobject in Python. I connect to the database with
conn = connectionForURI(connStr)
conn.makeConnection()
This succeeds, and I can do queries on the connection:
g_conn = conn.getConnection()
cur = g_conn.cursor()
cur.execute(query)
res = cur.fetchall()
This works as intended. However, I also defined some classes, e.g:
...