Hi all
I'm looking at an execution plan from a troublesome query.
I can see that 45% of the plan is taken up doing a table scan on a table with seven (7) rows of data.
I am about to put a clustered index to cover the columns in my query on a table with seven rows and it feels...wrong. How can this part of my query take up so much o...
I am having a tough time with this design problem and would appreciate any insight.
i have a doctors office that is provided certain privileges currently there are only 5 privileges but more could be added. Each of these privileges has a status of Yes or No, but there could be a finer grained status in the future and each of these privi...
Here's what I want to achieve:
I have a number of categories, each one with products in it.
I want to produce a report that shows various information about those products for each category. So I have a query that looks something like:
select
category,
count(products),
sum(product_price),
from product
group by category
So far so goo...
We're using Visual Studio Database Professional and it makes heavy use of SQLCMD variables to differentiate between environments while deploying.
I know there's several directives available for setting context (like :connect for server name). Is there a way within the script itself to force SQLCMD mode for execution? Part of our deploym...
+--------------+--------------+------+-----+-------------------+----------------
+
| Field | Type | Null | Key | Default | Extra
|
+--------------+--------------+------+-----+-------------------+----------------
+
| mag_id | int(11) | NO | PRI | NULL | auto_increment
|
| cat_id ...
Hi, I'm working with VS2010 and asp.net and build a SQL Server Database with some int and char values.
My problem is, that the char(50) automatically fills the unused chars with whitespaces like:
"foo "
What can i do to get only "foo"?
...
Is there a way to write a query in sql that will return the column names for the table?
e.g. if table Foo had columns bar and baz, this query would return 2 rows with "bar" and "baz" in them.
...
I have a table which stores a category mix for customers. The number of categories may change, but the breakdown must always be less than or equal to 100% for each customer.
custom type_ pct
------- ------- -----
Cust1 Type A .33
Cust1 Type B .17
Cust1 Type C .50
Cust2 Type A ....
SELECT * FROM `objects` WHERE (user_id IN ('7,8,12,9') AND visibility IN ('0,1'));
but it only returns the stuff corresponds to the second array's first element.
So it returns the same as like this:
SELECT * FROM `objects` WHERE (user_id IN ('7,8,12,9') AND visibility IN ('0'));
(I swapped the two values (of the visibility arg) an...
Hello, sorry for the poorish description it is really hard to explain what I am trying to do. But this is some pseudo:
foreach (row in Table1)
insert Table2 select * from getValuesTable('text', row.Column1)
I'm not too sure how to get that initial join together because it will not allow me to alias the returned table from getValue...
8-byte integers are now the default for Postgres 8.4, so it allows microsecond values to be stored.
I don't care too much about real microsecond precision (probably depends on OS capabilities?!) - But does Postgres guarantee, that the timestamp values (inserted by current_timestamp) are always different between any two transactions?
...
I receive a denormalized text file that must be loaded into a normalized table.
Denormalized table:
CustomerID -- Category -- Category2 -- Category3 -- Category4
1 -- A -- B -- C -- D
When this is normalized, it should look like:
CustomerID -- Category
1 -- A
1 -- B
1 -- C
1 -- D
What is the best way to write a T-SQL statement to ac...
I have the pivot
PIVOT
(
MIN(DateId)
FOR Stage IN
(
[Start], [Alpha], [Beta], [Release]
)
) as p
I only want the MIN for the [Start] column and Max for every other column.
How would I go about achieving this?
...
If there are any DBAs out there, I'm making a fairly large piece of software and one of the biggest issues presently is where to put the business logic. While Stored Procedures would be easier to fix on the fly, the processing requirements would probably slow the DB down tremendously. I also don't want to have all of the business logic h...
Hi,
I've got this strange problem which I'm sure is well known - When I insert a date like '20/08/2010' I mean it to be as 'dd/mm/yyyy' where MSSQL expects it to be 'dd/mm/yyyy'.
How can it be changed for MSSQL to expect 'dd/mm/yyyy' as the field format.
Thanks!
...
I have a table that has the following columns
Id
ForeignKeyId
AttributeName
AttributeValue
Created
Some of the data may look like this:
1, 1, 'EmailPreference', 'Text', 1/1/2010
2, 1, 'EmailPreference', 'Html', 1/3/2010
3, 1, 'EmailPreference', 'Text', 1/10/2010
4, 2, 'EmailPreference', 'Text', 1/2/2010
5, 2, 'EmailPreference', 'Htm...
I am trying to create a case statment saying if 1 day or less has passed between my 2 date parameters then do this otherwise do this.....
...
hello,
i work on application which is CRM. i would when a new user register on my database, i create a new database. By exemple if name's user is "Toto", i create a database "Toto.SQL" and i register Toto.SQL in my user's database. When Toto connect the application must load it with Toto.SQL. Have an idea to make this ??
Thx
...
I have a row in a MySQL column named tags.
In tags I have a series of keywords separated by commas. For this example lets use ice cream as the theme.. mmmmmmm.... Ice Cream :).
So in my tags row I have:
Vanilla, Strawberry, Coconut, Chocolate, Rocky Road, etc.
I also have a column in the same table named Ice Cream Shop. Each with j...
I am looking to replace values in a particular column. For example the following column values
column name
----------
Test1
Test2
Test3
Test12
Test14
should be (replacing est1 with rest1)
column name
----------
Trest1
Test2
Test3
Trest12
Trest14
I know this should be simple but not able to get the exact function. Any help is apprec...