Im a little confused about whether should I use a nested Subquery Or JOINS with distinct !!
which one of these will perform better and faster ?
any suggestions to do this query without distinct ?!?
SELECT distinct TOP(20) e.*, u1.UserName As Sender,
u2.UserName As Receiver, u1.Avatar AS SenderPic
FROM Friends f INNER JOIN Users u
ON...
Can someone please explain why this works. Here is the scenerio. I have a stored proc and it starts to run slow. Then I pick a parameter and declare a variable to house its value and in the proc use the declared variable instead of the parameter. The proc will then speed up considerably.
I think it has something to do with the cache...
I've been assigned the task of creating a table that stores an email signature for each username. The question is, how should I store the signature block? I could use a regular varchar type, but then how do I store the formatting metadata?
Any ideas or suggestions would be welcome.
Thanks!
...
I have a table of data. I have a field which shows date. I had set this column as Start Date. I want to create an additional column as End Date, where the End Date will be the Start Date of the next row. Can you give me a query of creating the End Date by taking the data of the Start Date in next row ?
...
I'm writing stored procs that are being called by a legacy system. One of the constraints of the legacy system is that there must be at least one row in the single result set returned from the stored proc. The standard is to return a zero in the first column (yes, I know!).
The obvious way to achieve this is create a temp table, put the...
I would like to know the performance issues associated with running managed code through SQL Server 2008. I've heard about some memory and speed issues.
Specifically, I want to implement a SHA256 hashing DLL and execute it as a sproc with SQL Server 2008.
Alternately, I could simply execute the hashing from my .Net app, then pass the ...
Let's say you have a notes table. The note can be about a particular account, orderline or order.
Notes that are about the account do not apply to any specific orderline or order.
Notes that are about the orderline also apply to the parent order and the account that is attached to the order.
Notes that are on the order also apply to t...
I need to keep a daily statistic of the count of records in a table.
Is there a way to automate counting the records daily and writing the result into another table? Maybe using a SQL Agent Job or something like that?
I'm using SQL Server 2008.
Thank you!
Edit:
If I delete today all records from 1/1/2010, the statistic still needs t...
I have the following table:
Id INT/PK
UserId INT/FK
CreatedDate DATETIME
ActivityMarker INT/FK
The table can be written to (incl. record updates) and deleted from (e.g. today I can delete a record from 1/1/2010). The CreatedDate contains the date the record was created. ActivityMarker and UserId can be updated.
What I need to do is k...
I am migrating data from one table to a new table. The old table uses FLOAT, and in the new table I am using DECIMAL as the field attribute.
I am using the following statement which worked fine:
CAST(OLD_COLUMN_NAME as DECIMAL(9,2) AS 'NEW_COLUMN_NAME'
that works like a charm until I hit the bump in the road. The old data is defined as...
Hi,
I am wondering how the row heights in an SSRS tablix are calculated.
For instance, I have data for which the displayed and grouped by columns are close enough to be identical. However, some rows will for some unknown reason have a massive height with a lot of blank space. If you inspect the HTML output you can see that these rows h...
Hello All,
What DataType should be a column to stored Encypted Data?
Can we have varchar instead varbinary => does there will have any odd consequences if we use varchar
Thanks
...
Hi,
I came into problem that I need to display the top 3 records for each aId in a comma separated string in one column (for eg. aId=151 ghghg,ghh, rgtg
) instead of the below result. Can anyone help me please?
Expertise
ghghg
ghh
rgtg
rtrt
ghgh
tyuyu
fgfg
yuu
dfdf
gtyy
dfdf
df
ssd
dfd
dfdf
fd
dfdf
d...
Hi,
I'm sure this has been asked but I can't quite find the right search terms.
Given a schema like this:
| CarMakeID | CarMake
------------------------
| 1 | SuperCars
| 2 | MehCars
| CarMakeID | CarModelID | CarModel
-----------------------------------------
| 1 | 1 | Zoom
| 2 | 1 ...
Hello everybody.
I have no enough experience on database systems. I have to connect to remote sql server and process some queries on it. How can i connect remote server by Entity Framework ?
...
Hi all...
I want only Hr and Min in time format so i did
select convert(varchar(20),GETDATE(),108) ===>> output is "12:57:54"
but i want only "12:57" this much so how i will do that in sql server
...
Does anyone know of any prebuilt SQL Server (Ideally) Thesaurus for handling English (and maybe eastern european) name expansions ?
Have a lookup thats runs as a full text query and it would be nice to be able to handle
Chris --> Christopher
Chris --> Christine
Bill --> William
Will --> William
If you don't know of such a list; is t...
I need to delete some text files when a certain database is dropped from SQL server (because they contain associated data that becomes out of date). I had a thought that I could use some sort of trigger to run a query to do that but I can't figure out where to put that or how to do it.
I'm using SQL server 2005 but likely to upgrade as ...
I have a table called [Sectors], which stores industry sectors. [SectorId] is defined as an INT and is the primary key of this table. These sectors are referenced throughout the database using the primary key, but there are no foreign key constraints for this primary key in the other tables.
Now there are 2 sectors in this table that no...
I have 2 tables, one called dbo.dd and one called dbo.gt.
where dbo.gt.v_products_model = dbo.dd.[Vendor Stock Code]
I would like to update the
field dbo.gt.v_products_price with the dbo.dd.[Dealer Ex]
Sorry, forgot syntax of SQL 2005 and in a jam!
...