Hi--
I routinely create constraints in my database tables, e.g., EndDate >= StartDate, etc. But I don't know of a way to create a constraint that works across tables. For example, let's say I have a 1:Many relationship between these two tables:
Admission(AdmitID (PK), AdmitDate,...)...
Is there a way to create a virtual table in a stored procedure that holds the results of a call to another stored procedure?
In other words, say I have sp1. Can I do something like this in sp2:
VirtualTable = EXEC(sp1 param1, param2)
SELECT<field list>
FROM VirtualTable
If so, what is the...
Hi,
I have a table with a column called AdmitDate and I need to know how many rows in that table have AdmitDates that are within 30 days of the AdmitDate of the previous row. I'm stumped about how to write such a query, or if it is even possible to do so. Can anyone please help?
thanks
Hi,
I'm trying to create a query in a database on one SQL Server that refers to a database on another SQL server. Even though the other Server is listed properly under "Security/Linked Servers," and all user permissions are correct, when I try to save the query, I get this error:
"Error 7405...
Hi--
I've got the following sp (not sure how to demark code in this forum):
=======================================================
CREATE PROCEDURE dbo.UP_Get_Program
@PACEId INT
AS
DECLARE
@Program VARCHAR(7)
SET @Program = (SELECT Program FROM...
How, if it is possible, does one set up a foreign key in one table to point to a primary key in a table that's in another database (same server)?
Thanks.
When you use an OR, will SQL Server evaluate the left part before it determines it is necessary to evaluate the right part? You know what I mean? For example:
a = 1 or b = 2
If a = 1, it's not necessary to evaluate the b = 2 part. Is SQL Server smart enough to figure this kind of thing out...
Hi,
How do I refer to a database on a different SQL Server from inside a view or stored procedure? Both servers are registered in MMC (or Enterprise Manager).
Thank you!
Does anyone know of a way to get the date and time that a view was last changed? I've tried looking in the sysobjects table, but it doesn't seem to be there...
Thanks
Hi--
I need to update all rows in a table that have a date in a datetime field that comes after a certain date. I'm not sure how to write that.
...
WHERE DateTimeColumn >= '9/1/2005'
I must need to convert the string value at the end of this WHERE clause to an actual datetime? Can someone...
Hi,
I have two queries that are almost alike. The difference is that one makes a few additional joins and projects a few additional columns from those additional joins. I'd like to avoid the duplication in the parts where they are alike.
I thought of making a view of the common part, then...
Hi--
I am scheduling a DTS package by right-clicking on it then clicking on Schedule Package... If, after I schedule a package, I right-click on it again to see how it was scheduled, I see the default screen without the scheduling info I had entered.
Can anyone please help me understand how...
Hi,
Is there a way to copy a DTS package from one database to another (on different SQL Servers, both of which are registered in Enterprise Manager)?
Thank you.
Hi,
I have a table with a smalldatetime column. I need to identify all records in that table that have dates in that column that are six months old or older. Can someone please tell me how I might do this?
Thank you.
Hi, I have a stored procedure that resembles the following structure:
SELECT projectionA
FROM TableA
JOIN
(SELECT projectionB
FROM TableB
UNION
SELECT projectionC
FROM TableC)
RIGHT JOIN TableD
The issue is this: On some...
Does anyone know how to tell reporting services that a group is not supposed to break from one page to another? I've looked in "Edit Group," and elsewhere and can't find anything.
Thank you.
Is there an easy way to copy a table from a database on one SQL Server to a database on another SQL Server? The SQL Servers are within one SQL Server Group in MMC. Also, the table does not exist at the target. I'm hoping for some command or interface (GUI?) that will create a new table at the...
Hi,
I have a table with an empty field that needs to be populated with data from a related table. In other words, if I do a join between this table and the related table, the value I need to populate the empty field with would be on the same row as the row that needs to be populated. I'm not...
I have a stored procedure that needs to refer to one of two tables depending on the value of a parameter. Here's what I know and don't know how to do:
DECLARE @ThisQuery varchar(8000)
SET @ThisQuery = 'Select * '
SET @ThisQuery = @ThisQuery + 'FROM '
(Here, I need to be able to append...
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.