Hello
How to check a value IS NULL [or] = @param (where @param is null)
Ex:
Select column1 from Table1
where column2 IS NULL => works fine
If I want to replace comparing value (IS NULL) with @param. How can this be done
Select column1 from Table1
where column2 = @param => this works fine until @param got some value in it and if is...
Hello,
sorry for the bad title, I don't know how to describe my problem.
I have the following table:
| ItemID | Date |
-------------------------
| 1 | 01.01.10 |
| 1 | 03.01.10 |
| 1 | 05.01.10 |
| 1 | 06.01.10 |
| 1 | 10.01.10 |
| 2 | 05.01....
Hi,
I have a table in which there are two columns : 1. import type, 2. Excel import template.
The second column - "Excel import template" should store the whole excel file.
How would I save excel file in databse...can I use binary datatype column, convert excel file to bytes and save the same ?
Thanks in advance !
...
I have the following query which have 1000 rows
select
staffdiscountstartdate,datediff(day,groupstartdate,staffdiscountstartdate),
EmployeeID
from tblEmployees
where GroupStartDate < '20100301' and StaffDiscountStartDate > '20100301'
and datediff(day,groupstartdate,staffdiscountstartdate)>1
order by staffdiscountstartdate desc
i ...
i have the following query to list the employees of two table.
i need to update the a.staffdiscountstartdate to '20100428' how to rewrite the following query for this?
select
a.employeeid,
b.employeeid
from
tblEmployees a
left join
tblCards b
on
a.employeeid=b.employeeid
where
Group...
goal: I have the string "1234432144" I want to only replace the first 2 4's with '10' so I would get '1231032144'
Is there a way to do this in tsql?
so far I have come up with the tsql substring() function
substring('1234432144', 4, 2)
which draws the 44 .. however how do i replace it within the existing string?
If i wrap a r...
Hiya Guys,
I'm trying to develop some code which pulls latest information only.
What it is when a user goes into a form there a subtable and everytime they change something it creates a new row in the colum called type12_OriginalNoteID which puts its own unique number in. Another field called type12_OriginalNoteID keeps the same number...
I have a table full of Dealers along with their latitude and longitude. I am trying to determine the top n closest dealers to any given lat and lon. I already have the function to calculate distance between locations, but I want to do as few calculations as possible (my table can contain many thousands of entries). Currently I have to...
Got a problem with a query I'm trying to write. I have a table that lists people that have been sent an email. There is a bit column named Active which is set to true if they have responded. But I need to count the number of consecutive emails the person has been inactive since either their first email or last active email.
For example,...
So I have some data that looks like this.
`USERID1 USERID2`
1 10
2 20
2 30
3 40
3 50
1 10
2 20
2 30
3 50
I want a query that produces the following
`USERID1 COUNT`
2 2
3 2
It's a group by query that shows me ...
On my SQL Server 2008 I have a stored procedure with a large number of parameters.
The first part of them is used in every call and parameters from the second part are used rarely. And I can't move the logic to two different stored procedures.
Is there a way to encapsulate all this parameters to a class or struct and pass it as a store...
I have a user-defined table type. I want to check it's existence before editing in a patch using OBJECT_ID(name, type) function.
What type from the enumeration should be passed for user-defined table types?
N'U' like for user defined table doesn't work, i.e. IF OBJECT_ID(N'MyType', N'U') IS NOT NULL
...
Does SQL Server 2005 maintain built-in, queryable, row-level last-modified timestamp metadata?
I'm doing some analysis on a database that did not include any sort of column to track a revision date/time stamp. I usually create columns for this purpose, but the designer of this database didn't, so I'm stuck with reconstructing history on...
I have been working on migrating some of our data from Microsoft SQL Server 2000 to 2008. Among the usual hiccups and whatnot, I’ve run across something strange. Linked below is a SQL query that returns very quickly under 2000, but takes 20 minutes under 2008. I have read quite a bit on upgrading SQL server and went down the usual paths ...
I have an issue with a deadlock in SQL Server that I haven't been able to resolve.
Basically I have a large number of concurrent connections (from many machines) that are executing transactions where they first delete a range of entries and then re-insert entries within the same range with a bulk insert.
Essentially, the transaction lo...
I have a table called,tblClient with an encrypted column called SSN.
Due to company policy, we encrypted SSN using a symmetric key (chosen over asymmetric key due to performance reasons) using a password.
Here is a partial LIKE search on SSN
declare @SSN varchar(11)
set @SSN = '111-22-%'
open symmetric key SSN_KEY decrypt by p...
Is there a way to find out when a stored procedure or table was last modified? I tried checking the properties via SQL Management Studio, but only found the creation date.
Thanks!
...
Hi All,
I have a SQL 2005 TSQL script which sets up my FT Catalog and Indexes, but I would like to also create a Population schedule for these indexes via the same Code, can anyone point me in the right direction.
Thank you
Matt
...
hi folks,
i need to get splited intervals and the number of overlapping intervals, eg
basedata:
interval A: startTime 08:00, endTime 12:00
interval B: startTime 09:00, endTime 12:00
interval C: startTime 12:00, endTime 16:00
interval D: startTime 13:00, endTime 14:00
now i have a separate interval from 10:00 to 15:00 and have to de...
How to find the worst performing queries in SQL Server 2008?
I found the following example but it does not seem to work:
SELECT TOP 5 obj.name, max_logical_reads, max_elapsed_time
FROM sys.dm_exec_query_stats a
CROSS APPLY sys.dm_exec_sql_text(sql_handle) hnd
INNER JOIN sys.sysobjects obj on hnd.objectid = obj.id
ORDER BY max_logical_r...