Some how some records in my table are getting updated with value of xyz in a certain column. Out of hundred of stored procedures, functions, triggers, how can I determine which code is doing this action. Is there a way to search through the database some how through each and every script of the code?
Please help.
...
I have two tables A and B... A and B can be joined by a common column. A and B will have some rows that match on the join column. But A has some rows that B doesn't have, and B has some rows that A doesn't have.
A LEFT OUTER JOIN from A to B will give all rows in A, filling in NULLS for the B columns that couldn't be matched. A R...
Does sql server cache the execution plan of functions?
...
I'm not sure of the terminology here, so let me give an example. I have this query:
SELECT * FROM Events
--------------------
Id Name StartPeriodId EndPeriodId
1 MyEvent 34 32
In here, the PeriodIds specify how long the event lasts for, think of it as weeks of the year specified in another table if that helps. No...
I have a view that I want to be converted into JSON. What is the SQL that I can use to produce on the server the JSON string needed to be returned?
...
I need to branch my T-SQL stored procedure (MS SQL 2008) control flow to a number of directions:
CREATE PROCEDURE [fooBar]
@inputParam INT
AS
BEGIN
IF @inputParam = 1
BEGIN
...
END
ELSE IF @inputParam = 3
BEGIN
...
END
ELSE IF @inputParam = 3
BEGIN
...
END
END
Is there any other ways? For example, in C...
I have a database table in SQL Server 2008 with 5 nvarchar(max) columns. We're using the CONTAINS function to look for text in these columns.
We can look in all five columns using this kind of query:
SELECT *
FROM SomeTable ST
WHERE CONTAINS( (ST.ColumnA, ST.ColumnB, ST.ColumnC, ST.ColumnD, ST.ColumnE) , '"Strawberry"')
Now we want ...
I am trying to work up a general ledger appearance in an asp.net page. Here's the data i have so far.
AccountName Desc Type Amount
-----------------------------------------
Account1 Stuff Debit 5000
Account1 Stuff Credit 4000
Account2 Other Debit 3000
Account2 Other Credit 6000
A...
There are two SQL tables:
Parents:
+--+---------+
|id| text |
+--+---------+
| 1| Blah |
| 2| Blah2 |
| 3| Blah3 |
+--+---------+
Childs
+--+------+-------+
|id|parent|feature|
+--+------+-------+
| 1| 1 | 123 |
| 2| 1 | 35 |
| 3| 2 | 15 |
+--+------+-------+
I want to select with single query every row fro...
I have a report which needs to total up the number of registrations per week, over the last ten weeks and display it as
"Week Ending October 10th, 2009" 500"
"Week Ending OCtober 3rd, 2009" 400"
"Week Ending September 26, 2009" 1000"
etc...
Here is my query:
SELECT Count(*) as [Total]
,Week = DateAdd(day, -1 * da...
i need to start at a year-month and work out what the date it is in a given week, on a given day within that week..
i.e
year: 2009
month: 10
week: 5
day-number: 0
would return 2009-10-25 00:00:00 which is a sunday. Notice week 5, there is no day 0 in week 5 in 2009-10 as the sunday in that logical week is 2009-11-01 00:00:00... so w...
I'm having an issue I'm generating sudoku puzzles and the solution to the puzzle are being stored in this format:
xxxxxxxxx xxxxxxxxx xxxxxxxxx xxxxxxxxx xxxxxxxxx xxxxxxxxx xxxxxxxxx xxxxxxxxx xxxxxxxxx
8 spaces between the 9 sets, I cannot seem to query the row, it returns a blank row..
Is this because there is spaces? If I do a sel...
I have two tables
order [ order_id ]
order_line [ order_id, product_id, cat_id ]
I want to select every order & associated order_line,
but I want row per order, and i only want to select cat_id from order_line
so i want a result like this..
results:
[0] order_id, cat_id1 , cat_id2, cat_id3
[1] order_id, cat_id
Possible?
...
I have a inline select statement to calculate the product of the set of values.
Since SQL Server 2005 doesn't have a built in Product aggregate function, I am using LOG/EXP to get it.
My select statement is:
(select exp(sum(log(value))) from table where value > 0)
Unfortunately I keep getting the following error:
Msg 3623, Level 16...
I've got a simple table and want to store its content into a xml on the harddrive. There should be one root element for the whole table, one element per table row and one child element per table column.
What possibilities do I have?
Thanks a lot
Tomas
...
Hi All,
I am wanting to perform a Threshold query, whereby one would take the Value of a field from Today, and compare it to the value from yesterday, this query would look something like this, but obviously, it is wrong, and I can't find how to do it:
select
TableB.Name,
TableA.Charge,
(
select Charge
from Tabl...
I'm currently searching for an easy way to serialize objects (in C# 3).
I googled some examples and came up with something like:
MemoryStream memoryStream = new MemoryStream ( );
XmlSerializer xs = new XmlSerializer ( typeof ( MyObject) );
XmlTextWriter xmlTextWriter = new XmlTextWriter ( memoryStream, Encoding.UTF8 );
xs.Serialize ( x...
Hello everyone,
I have two tables - let's call them dbo.ValuesToReduce and dbo.Reserve
The data in the first table (dbo.ValuesToReduce) is:
ValuesToReduceId | PartnerId | Value
-------------------------------------
1 | 1 | 53.15
2 | 2 | 601.98
3 | 1 | 91.05
4 ...
hi there
I'm tryin to use SQL to build a comma separated list of cat_id's
the code is:
declare @output varchar(max)
set @output = null;
select @output = COALESCE(@output + ', ', '') + convert(varchar(max),cat_id)
edit: changed '' to null, STILL same.
but the output im getting is like so:
, 66 , 23
the leading comma sh...
Hi
Two table are tied with each other because of FK constraint. I am trying to update these tables by disabling ALL Trigger but still getting the following error :-
The UPDATE statement conflicted with the FOREIGN KEY constraint "FK_TEST_REFERRING_REFPHYSI". The conflict occurred in database "ccdb", table "dbo.RefPhysician", column 'R...