Im using SQL 7.0 and deleting a rows with cursor from user tables. If productID in exists in one of my ProductHistory tables and if the productID in the master table "Products" is less than a certain date then I want to delete it. I get an error msg (follows):
Server: Msg 137, Level 15...
Im new to sql server.
I have two tables, I need to write a query that will take the values out of one table if they exist in another table.
Each table has one column only and they are varchar(250). Each table has approx 20,000 rows.
I need to remove entries from table1 that already exist in...
Im new to sql and Id like to exclude null values from my query. When I run my query (in query analyzer) I still see the null values that I want to exclude.
select col_a
from tabl_a (nolock)
where (NOT (col_b IS NULL))
Any ideas? Thanks guys.
I have an if statement that I need to alter but Im unsure of where to put the ( )'s and <>
IF (SELECT COUNT(msecs) FROM [tablename] WHERE (CONVERT(int, msecs)/1000)/3600 >2 )>=1
BEGIN ......
I need ">2" part show greater than 1 and less than 3.
Thanks for you help!
create procedure sp_display_activity @loginid int, @date datetime
as
select * from LoginActivity
where [date] = @date
and loginid = @loginid
Im having difficulty returning values from my stored procedure
that accepts 2 parameters of "date" and "loginID". I get an...
Does anyone know what Im doing wrong? I get an error msg saying invalid use of RAND within a function. Thanks!
CREATE FUNCTION RandString
-- Input length of string to be returned
(@LenString int
)
RETURNS char(50)
AS
BEGIN
DECLARE @position int, @AtoZstring char(26), @ResultString...
If I have the following...
SELECT DISTINCT STREET
FROM TableA
UNION
SELECT DISTINCT STREET DEPENDENT_STREET
FROM TableA
WHERE STREET IS NOT NULL AND DEPENDENT_STREET IS NOT NULL
...and for each result returned I want to do
SELECT TEXT_ID
FROM TableB
WHERE STREET=['a parameter I will...
Hi,
I think I need to write a function to avoid using this query over and over again.
CAST(DATEPART(YEAR,getdate()) AS VARCHAR) +
REPLICATE('0',2-LEN(CAST(DATEPART(MONTH,getdate()) AS VARCHAR))) +
CAST(DATEPART(MONTH,getdate()) AS VARCHAR) +...
Hiya, I have a table listing 2000 item_names such as 'coastal', 'mountain', 'rescue' and so on. Each of these items has a task_id which represents the amount of time that may elapse before the 'item_instructions' for each item should be completed. I need to reformat the task_id column so that...
I need to get the values from a column (small example shown on the left) convert them (it "sort-of" represents minutes) from an excel file into a new sql format (on the right) which represents a new incrementing ID (note: single digits always prefixed by '0') and then hours (HH) and...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.