|
I have this query. but it is not work with the session
Please help me.
SELECT AdCampaign.CampaignName, AdCampaign.AdType AS [Campaign Type], AdCampaign.Status, AdCampaign.Date AS [Start Date], AdCampaign.Clicks, AdCampaign.Impr, AdCampaign.DailyBudget AS [Daily budget] FROM Account INNER JOIN AdCampaign ON Account.ID = AdCampaign.AccountID WHERE (Account.EmailAddress = 'Session["Email_Address"]') AND (Account.Pass = 'Session["Password"]')
|
|
|
|
|
And what is the error message?
|
|
|
|
|
We have a group of users who can access various locations within the datacenter.
For the largest group of users, if they can access one location they can access all of the locations.
For a very small population, the user can only access the office and not the data center locations. These users are causing me a problem.
The query is aimed at basically giving me the count of active locations. But in the mixed case I get BOTH a record with a null count AND a record with access count. In otherwords: Amy can access only the office and cannot access dc1 or dc2. The query returns Amy's record as Amy, null and Amy, 1. I want it to return ONLY Amy, 1.
Any suggestions on the changes I need to accomplish that?
Here is the current query:
SELECT dbo.ContactMaster.BmcCustKey,
(SELECT COUNT(dbo.LocationAccessGrant.CanAccessLocation)
WHERE (dbo.LocationAccessGrant.CanAccessLocation = 1)) AS AccessCount
FROM dbo.ContactMaster LEFT OUTER JOIN
dbo.LocationAccessGrant ON dbo.ContactMaster.CompanyID = dbo.LocationAccessGrant.CompanyID AND
dbo.ContactMaster.ContactIdentity = dbo.LocationAccessGrant.ContactIdentity
GROUP BY dbo.ContactMaster.BmcCustKey, dbo.LocationAccessGrant.CanAccessLocation
ORDER BY dbo.ContactMaster.BmcCustKey
|
|
|
|
|
Not sure I've understood you properly, but your subquery doesn't look correct.
So try something like this:
SELECT dbo.ContactMaster.BmcCustKey
,Sum(CASE WHEN dbo.LocationAccessGrant.CanAccessLocation = 1
THEN 1
ELSE 0
END) accesscount
FROM dbo.ContactMaster
LEFT OUTER JOIN dbo.LocationAccessGrant
ON dbo.ContactMaster.CompanyID = dbo.LocationAccessGrant.CompanyID
AND dbo.ContactMaster.ContactIdentity = dbo.LocationAccessGrant.ContactIdentity
GROUP BY dbo.ContactMaster.BmcCustKey
,dbo.LocationAccessGrant.CanAccessLocation
ORDER BY dbo.ContactMaster.BmcCustKey It should take care of your null values
"When did ignorance become a point of view" - Dilbert
|
|
|
|
|
Hi,
How many concurrent we can have in SQL Server 2005 Express?
Does it make difference with the operating system like windows server 2003/2008 or winxp pro?
And I am getting error while connecting to the sql server 2005 express that the remote server has refused the remote connection (Error no. 26) though it was working fine before couple of days (I have enabled the remote connection via/pipeline/tcpip and also added in firewall exception port 1433. It was working fine before).
After that I have just restarted my server and its works fine! What can be wrong in this? May be the number of concurrent connection has reached!
Thanks,
Divyesh
|
|
|
|
|
I don't see a connection limitation in SQL server express, but there are indeed tcp connection limitations in windows XP. (Microsoft wants you to buy the server if you're doing server work).
|
|
|
|
|
This[^] fixes that little problem.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
No, not really. This was introduced to limit the number of half-open connections (typically session in the SYN_WAIT state). A number of worms were rampant at that time, and they opened oodles of connections to systems simultaneously. P2P systems typically do likewise, so this patch was developed to allow P2P to run. I doubt that this is the OP's problem.
I was thinking more in the line of this[^], but MS seems to imply that they don't enforce the inbound connection limit, except for SMB operations. So if the SQL server is connecting though named pipes, yes it would be a problem, but normal TCP connections should be okay.
|
|
|
|
|
hi,
I was trying to update the Cyrillic characters · Serbian characters in sql server database, but everytime i shows ??? after updation
Please suggest something.
Thanks
|
|
|
|
|
Do you use VARCHAR or NVARCHAR? Only NVARCHAR will do!
|
|
|
|
|
Thanks for replying...
If I have to search for keyword abcurlф in the table
what should be the query in this case?
Presently it is not displaying any result if i search even only with ф
and displays those records which have ? character
|
|
|
|
|
In the Employees table of Northwind database, I changed the FirstName of an entry to "abcurlф". Now I do in SQL Enterprise Manager:
SELECT *
FROM Employees
WHERE (FirstName LIKE N'%ф%')
and that returns exactly the row where I made that change.
Note that an "N" is required before the search term - LIKE '%ф%' does not work.
|
|
|
|
|
I have a database with a master - detail relationshio between two tables. The database is basically a snapshot in time for each office. so imagine that my master table is:
id (auto increment), date, office_id
1 , 2010-4-1, 100
2 , 2010-4-2, 100
3 , 2010-4-3, 100
4 , 2010-4-4, 100
5 , 2010-4-1, 101
6 , 2010-4-2, 101
7 , 2010-4-3, 101
8 , 2010-4-4, 101
I want to get the id number for the last update date from the master table so I did the following:
SELECT id, max(upload_date) as upload_date, office_id from master group by office_id
What I want is the id number associated with the latest date, so I WANT
id, date, office
4, 2010-4-4,100
8, 2010-4-4,101
What I get is:
1, 2010-4-4,100
5, 2010-4-4,101
I get the max date, but the first id number. Normally I'd do a cursor in a procecure to get it, but the ISP has to grant the pivs each time the sp is modified so I am trying to do this in a simple query since it is called from php.
As a work around, I am doing a max(id) as well since I figured that the highest id would always be associated with the latest date, but I don't want to make that assumption.
Does anyone know how to build the query correctly to get the id associated with the latest date?
|
|
|
|
|
I'm not sure, I think you need to add some sorting, try "ORDER BY date DESC" on top of your grouping.
|
|
|
|
|
I'm little bit confused; are we trying to get the current inserted / updated data using the dateTime criteria?
Thanks
Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
No, I was suggesting to get things sorted within each group, but MySQL isn't accepting a "ORDER BY ... GROUP BY ..." qualification.
|
|
|
|
|
Yep, I got your point.
Thanks
Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
You can try SQL SCOPE_IDENTITY function to get the last identity value inserted into an identity column in the same scope. Or you can also try in a trigger which something like:
DECLARE @id int = 0
SET @id = (SELECT id FROM INSERTED )
Thanks
Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
I wasn't sure what MySQL supports so I kept out of it!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Try the following
select a.id
,a.upload_date
,a.office_id
from ( select max(m.upload_date) max_upload_date
,m.office_id office_id
from master m
group by m.office_id
) tmp
,master a
where a.upload_date = tmp.max_upload_date
and a.office_id = tmp.office_id
;
You need to be joining the table on itself, though it is more a view on itself.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
|
|
|
|
|
Hi,
Is there any way to find all stored procedures which are being called inside the main procedure? This can go deeper at last level inside the main one. I have tried the available option for "right click" > "View Dependancies" but it does not show the procedures called by EXEC statement. Please correct me if I am wrong here.
My problem is - I have a procedure which calls multiple other procedures inside it. Also these called procedures again might have called other procedures inside them. Now I need to find a list of all such dependent procedures for my main procedure.
Thanks in advance for your inputs!
Anil
|
|
|
|
|
There is an answer to this on SQLServerCentral.com here[^]. You might have to sign up to view it, can't remember, but it is a reputable and useful site.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi
Try the following:
Link 1 : sql-server-get-the-list-of-object-dependencies-sp_depends-and-information_schema-routines-and-sys-dm_sql_referencing_entities/[^]
Or
DECLARE @StringToSearch NVARCHAR(MAX)
SET @StringToSearch = 'ENTER_SP_TO_SEARCH'
SELECT
[name],
(
SELECT
OBJECT_DEFINITION(obj2.object_id) AS [text()]
from sys.all_objects obj2
where obj2.object_id = obj1.object_id
FOR XML PATH(''), TYPE
) AS Obj_text,
[type] as ObjType
FROM sys.all_objects obj1
WHERE OBJECT_DEFINITION(object_id([name])) LIKE '%' + @StringToSearch + '%'
Thanks
Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
Hello. I am getting the following error when trying to connect:
"An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (.Net SqlClient Data Provider)"
1) I tried seeing what services are running and nothing with SQL Server is listed.
2) I ran the Surface Area Configuration and the following message immediately pops up:
"No SQL Server 2005 components were found on the specified computer. Either no components are installed, or you are not an administrator on this computer. (SQLSAC)"
What in blazes is going on?
Thanks.
|
|
|
|
|
This tends to be a misleading, catch all error message. Assuming you actually have SQL installed and can see the database in SSMS then I would delete the credentials you are using and re create them. This may be cause by a restore from another server corrupting the user details.
Never underestimate the power of human stupidity
RAH
|
|
|
|