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...
by the way...when I use this query in a View, my query doesnt return any null values (which is what I want). So why doesnt this work in query analyzer?
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!
Ok, I havent released this to users yet as I cannot get it working myself! lol. I AM placing quotes around the date tho.
To explain further I have in my table:
Login Date Name
---------------------------------------
1433 12/01/2004 12:15:02 Smith
I want to...
The user will type the date parameter in query analyzer. Im not sure whats going wrong as Im entering my date parameter with quotes around it. How would I convert the users input and add the time to it?
Hmmm this doesnt work. In the table, my date column is datetime datatype and displays dates/times as "12/01/2004 12:00:00". I want my user to type only "12/01/2004" into the stored procedures date parameter and for the procedure to display results without having to specify...
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...
Sorry, I wasnt very clear on that!
TableA contains column named 'street' which is common to TableB.
The first query...
SELECT DISTINCT STREET
FROM TableA
UNION
SELECT DISTINCT STREET DEPENDENT_STREET
FROM TableA
WHERE STREET IS NOT NULL AND DEPENDENT_STREET IS NOT NULL
... will produce...
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...
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.