Is there a way to truncate tables with constraints ?
I tried to DEACTIvATE with this:
DECLARE @SQLtxt varchar(max)
SET @SQLtxt = '-- DESACTIVER LES CONTRAINTES' + CHAR(10)
SELECT @SQLtxt = @SQLtxt + 'ALTER TABLE [' + name + '] NOCHECK CONSTRAINT ALL;' FROM sys.tables
PRINT @SQLtxt
Of course, it didn't worked. I have to drop the const...
I'm writing a reporting stored procedure. I want to get the number of non-Acknowledged and non-Invoiced Purchase Orders, with the ability to (optionally) filter on CustomerID.
What I have below works as expected, but I worry that a) it's slow and b) there's duplication in the CustomerID portion of the WHERE clause.
How would you write...
I have a hierarchical query in Oracle 10 SQL that used to work. However, I removed the materialized view it was based on, and now I can't get it to come out properly, even leaving that view out altogether.
The original query looked like this:
select oh.name, oh.description
, sys_connect_by_path(groupname, ':') "Groups"
, (select c...
I have a textbox and a search button i trying to search file names in a database table and display them in a datatable...
private void GetSearchResults(string machineID, string searchFileName)
{
DataTable dt = new DataTable();
SqlConnection connection = new SqlConnection();
connection.ConnectionString = ConfigurationManager....
Hi, so...
I have a huge list ranked by various values (eg. scores)
So I grab the list ordered by these values:
players = Player.objects.order_by('-score', '-karma')
I would like to:
Grab a player and get the neighbouring players
P1 score:123
P2 score:122
YOU! score:110
P3 score:90
P2 score:89
Grab the...
Using SQL Server 2005:
I have one stored proc that calls several others within it. One code segment, as an example, goes:
INSERT INTO Log (...) VALUES (A...)
EXECUTE StoredProcA params...
INSERT INTO Log (...) VALUES (A...)
INSERT INTO Log (...) VALUES (B...)
EXECUTE StoredProcB params...
INSERT INTO Log (...) VALUES (B...)
It appe...
I am most confused with this one, so i d better ask the experts!
These are the rows returned by a custom query of mine.
Col1 Col2 Result
Font Bold a
Font Bold b
Font Bold a
Font Italic a
Is there any way of using selecting count in the above (table) results in order getting this one?
Col1 Col2 ResultA ResultB
...
Hello, I want to know which record is the last inserted on Detail Table B in the following order... for example If I have :
1 row Header Table A
--------------------
1 row Detail Table B
2 row Detail Table B
3 row Detail Table B
4 row Detail Table B (last)
I want to do some T-SQL or run a procedure if the 4 row is inserted... Thanks i...
I want to rename my SALES cube to SALES_2009 and put a new cube called SALES. When I rename it, the ID remains as SALES so my new cube now is called SALES, but it's internal ID is SALES_2010 (and my old cube is called SALES_2009, but the internal ID is SALES).
Can the ID of a SSAS database be changed?
I have tried the properties windo...
Hello all,
I have a Journal_Entry table, with a Primary Key of Journal_Entry_ID, and (among other columns) an Entry_Date column.
I'm trying to do a query that selects the most recent Entry_Date -- via a SELECT MAX(Entry_Date) -- but the problem is that the user may have logged more than one entry on a given date. So if the user logged ...
Hey guys,
I am working on a project for a client and going through the initial database design. The project will be a simple web app for tracking processes and their outcomes within a matrix diagram, I am looking for a good way to store these in relational tables.
Right now I am thinking I have a general table for Routines which the x...
I have a program in access that is using some linked ODBC tables. I had originally had a query that contained the following INNER JOIN:
FROM Neptune_FN_Analysis
INNER JOIN Neptune_prem ON Neptune_FN_Analysis.PremID = Neptune_prem.premice_id
This worked just fine until the column Neptune_prem.premice_id got changed from a number to a...
Normally I would just do this in the code itself, but I am curious if this can be accomplished efficiently in TSQL.
Table 1
Date - Value
Table 2
Date - Discount
Table 1 contains entries for each day. Table 2 contains entries only when the discount changes. A discount applied to a value is considered valid until a new discount is en...
On a page which shows a specific object I need to display related objects for that object based on tags. ´The object with the most matching tags should be at the top. Basically I somhow need to identify how many tags for each object that match the object on the page and display the top results.
My db schema:
Table Object
------------
...
Let's say I wanted to create a sql script and do something like this:
DECLARE @SomeVariable int
SET @SomeVariable = 'VALUE'
FROM someTable
--do stuff with @SomeVariable
GO
CREATE PROCEDURE myProcedure
(
@MyParameter
)
AS
SET NOCOUNT ON
--Do something
--Do something using @SomeVariable
SET NOCOUNT OFF
RETURN 0
GO
I can't, because...
I know it's possible, but I'm not experienced enough to know how to do subqueries.
Here's the situation:
Table 1:
+--------------------+--------------------+
| v_id | v_name |
+--------------------+--------------------+
| 1 | v_name1 |
+--------------------+--------------------+
| et...
I have a test console app that is executing sql scripts to create a database and its tables, then inserting data. I use DAO to create, retrieve, update, and delete from the tables and then try and drop the database, but it can't because it says it is currently in use. How do I kill the connection? Through debugging and running a sql scri...
Hi all,
My current workplace uses the standard Spring/Hibernate/JSP mix to serve content to its Flex client via XML. There are many ways in which the data is accessed, but the most prevalent one is via direct SQL calls to the database and a manual conversion to XML.
The trouble is that as the application grew bigger, the SQLs became mu...
I have 4 tables
Table1 (employee)
id name
--------------------
1 a
2 b
Table2 (appointment)
id table1id table3id table4id sdate edate typeid
-----------------------------------------------------------------------------------
1 1 1 1 1/1/09 NULL 100...
This is a follow-up question to my previous one.
Situation:
Table 1:
+--------------------+--------------------+
| v_id | v_name |
+--------------------+--------------------+
| 1 | v_name1 |
+--------------------+--------------------+
| etc...
Table 2:
+--------------------+--------...