Hi,
i looked sqlserver dateformat codes but i couldnt find dd.mm.yyyy hh:mm format in the list.German Date Format(Code is 4) works me but it doesnt contain hh:mm.Does someone this format's code?
I have a simple user production report where daily quotas are tracked. The sql returns a weeks worth of data for all users and for each day it tracks their totals. The problem is if they are out for a day and have a zero production for that day then the result query just skips that day and leaves it out. I want to return days even if the table has no entries for the person on that day.
table:
user date
andy 3/22/10
andy 3/22/10
andy 3/23/10
andy 3/24/10
andy 3/26/10
result:
andy
3/22/10 2
3/23/10 1
3/24/10 1
3/25/10 0
3/26/10 1
So my question is how do I get the query to return that 3/25/10 date with a count of 0.
(current query I'm using):
SELECT A.USUS_ID as Processor, CONVERT(VARCHAR(10),A.CLST_STS_DTM,101) as Date,
COUNT(A.CLCL_ID) as DailyTotal
FROM CMC_CLST_STATUS A
WHERE A.CLST_STS_DTM >= (@Day) AND
DATEADD(d, 5, @Day) > A.CLST_STS_DTM
GROUP BY A.USUS_ID, CONVERT(VARCHAR(10),A.CLST_STS_DTM,101)
ORDER BY A.USUS_ID, CONVERT(VARCHAR(10),A.CLST_STS_DTM,101)
I have a table of users (User), and need to create a new table to track which users have referred other users. So, basically, I'm creating a many-to-many relation between rows in the same table.
So I'm trying to create table UserReferrals with the columns UserId and UserReferredId. I made both columns a compound primary key. And both columns are foreign keys that link to User.UserID.
Since deleting a user should also delete the relationship, I set both foreign keys to cascade deletes. When the user is deleted, any related rows in UserReferrals should also delete.
But this gives me the message:
'User' table saved successfully
'UserReferrals' table Unable to create relationship 'FK_UserReferrals_User'. Introducing FOREIGN KEY constraint 'FK_UserReferrals_User' on table 'UserReferrals' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints. Could not create constraint. See previous errors.
I don't get this error. A cascading delete only deletes the row with the foreign key, right? So how can it cause "cycling cascade paths"?
Thanks for any tips.
The Ubuntu WIKI https://help.ubuntu.com/community/IrcServer it lists few IRC servers you can use in Ubuntu. My question is which one is you favorite one and more secure. I will also need one that will allow me to monitor rooms for regular expressions and run some scripts if regexp matches.
Thanks
I've been using GROUP BY for all types of aggregate queries over the years. Recently, I've been reverse-engineering some code that uses PARTITION BY to perform aggregations. In reading through all the documentation I can find about PARTITION BY, it sounds a lot like GROUP BY, maybe with a little extra functionality added in? Are they two versions of the same general functionality, or are they something different entirely?
Hi everyone,
I'm having some trouble with this statement, owing no doubt to my ignorance of what is returned from this select statement:
declare @myInt as INT
set @myInt = (select COUNT(*) from myTable as count)
if(@myInt <> 0)
begin
print 'there's something in the table'
end
There are records in myTable, but when I run the code above the print statement is never run. Further checks show that myInt is in fact zero after the assignment above. I'm sure I'm missing something, but I assumed that a select count would return a scalar that I could use above?
Hi,
I have a table, and it is returning the data as -
Column1 Column2 Column3 Column4 Column5 Column6
-------------------------------------------------------------------
6 Joy Mycity NZ 123456 [email protected]
I need to disply it as -
SingleColumn
-----------------------
6
joy
mycity
NZ
123456
[email protected]
How do I do it?
Hi! I need to change the type of my primary key column on a table from int to guid. The database already has data that I don't want to lose, and there are foreign keys to consider. Is there a painless way to do this or do I have to manually do it through a big a** script?:) I would appreciate any suggestions
Hi,
I am trying to use Clipboard API (in Delphi) to extract images from Word documents.
my code works OK in Windows XP/2003 but in windows 2008 64 bit it doesn't work.
in win 2008 i get an error saying that Clipboard.Formats is empty and doesn't contain any format.
The image seems to be copied to the Clipboard (i can see it in the clipboard via Word) but when i try to ask the clipboard what format does he have it said it doesn't have any formats.
how can i access the clipboard programmatically on win 2008/Vista?
from what i know of 2008 64 bit, it might be a security issue...
here is the code snippet:
This is how i am trying to copy the Image to the clipboard:
W.ActiveDocument.InlineShapes.Item(1).Select; // W is a word ole object
W.Selection.Copy;
and this is how i try to paste it.
Clipboard.Open;
Write2DebugFile('FormatCount = ' + IntToStr(Clipboard.FormatCount)); // FormatCount=0
For JJ := 1 to Clipboard.FormatCount Do
Write2DebugFile('#'+ IntToStr(JJ) + ':' + IntToStr(Clipboard.Formats[JJ]));
If (Clipboard.HasFormat(CF_BITMAP)) or
(Clipboard.HasFormat(CF_PICTURE)) or
(Clipboard.HasFormat(CF_METAFILEPICT)) then // all HasFormat calls returns false.
Begin
Jpeg := TJPEGImage.Create;
Bitmap := TBitmap.Create;
Bitmap.LoadFromClipboardFormat(cf_BitMap,ClipBoard.GetAsHandle(cf_Bitmap),0);
Jpeg.Assign(Bitmap);
Jpeg.SaveToFile(JpgFileN);
try Jpeg.Free; except; end;
ResizeImage(JpgFileN,750);
Write2DebugFile('Saving ' + JpgFileN);
End
else Write2DebugFile('Doesnt have the right format');
Thanks in advance,
Itay
How do you specify the the row terminator when outputting query results using sqlcmd?
bcp is not an option.
sqlcmd -E -s" " -Q "Select * From SomeTable" -o C:\Output.txt -W
What is the default row terminator?
Hi ,
I guess I can extend the base providers to manipulate the base layout etc.Is there any place where I can get the java source code for default providers? Where are the classes for these default providers copied to ?What are list of things that I can manipulate by extending base containers? Is there a comprehensive documentation on methods that i can override?
Thanks a lot for your time!!
Regards,
Vivek
Is there a way to use the SQL Model (dbml) builder in VS2010 using SQLServer2000?
It works fine in VSExpress2008 + VS2008 but throws an "Upgrade SQL to 2005" error in VS2010 which seems a tad unreasonable.
I'm embarking on a project in which users will author, save, and share their own maps over the web. We will provide them with a large number of feature classes, but users will effectively author their own maps, map symbologies, etc. Furthermore, they will create and edit their own feature classes, which they can both map and share with other users.
The model for AGS map services seems to be: author a map in ArcMap, save an MXD/MSD, publish. I'm struggling to understand how this can help us build a dynamic web mapping platform as described above. Can anyone offer some tips on how to go about it?
I'm just now created Dynamic Data Entities Web Site.
And I have got a problem with image type. for all sql data types generated html elements by fieldTemplate. So, how can I create fieldtemplate for image-view, and image-upload ?
Hi all,
I am not able to install GP 10.0 in my system, pls somebody help me with the steps how can i install GP 10.0 in my system. I have windows XP service pack 2 OS. Going to work with GP 10.0 with SQL 2000 Database. I will be really appreciate if somebody help me with installation steps of GP 10.0 and SQL 2000. I am really fed up with installing GP 10.0 and SQL 2000. Pls help me...
Thanks,
Rahul
Context
I am fairly new to database design (=know the basics) and am grappling with how best to design my database for a project I am currently working on.
In short, my database will keep a log of which employees have attended certain health and safety courses throughout the year. There are multiple types of course e.g. moving objects, fire safety, hygiene etc.
In terms of my database design I need to accommodate the following:
Each location can have multiple
divisions
Each division can have multiple
departments
Each department can have multiple
functions
Each function can have multiple job
roles
Each job role can have different
course requirements
Also note that the structure at each location may not be the same e.g. the departments within divisions are not the same across locations and the functions within departments may also differ.
Edit - updated to better articulate problem
Let's assume I am just looking at Location, Division and Department and I have my database as follows:
LocationTable DivisionTable DepartmentTable
LocationID(PK) DivisionID(PK) DepartmentID(PK)
LocationName DivisionName DepartmentName
There is a many-to-many relationship between Locations and Divisions and also between Departments and Divisions.
Suppose I set up a 'Junction Table' as follows:
Location_Division
LocationID(FK)
DivisionID(FK)
Using Location_Division I could easily pull back the Divisions for any Location.
However, suppose I want to pull back all departments for a given Division in a given Location.
If I set up another 'Junction Table' for Division and Department then I can't see how I would differentiate Division by Location?
Division_Department
DivisionID(FK)
DepartmentID(FK)
Location_Division Division_Department
LocationID DivisionID DivisionID DepartmentID
1 1 1 1
1 2 1 2
2 1 2 1
2 2 2 2
Do I need to expand the number of columns in my 'Junction Table' e.g.
Location_Division_Department
LocationID(FK)
DivisionID(FK)
DepartmentID(FK)
Location_Division_Department
LocationID DivisionID DepartmentID
1 1 1
1 1 2
1 1 3
2 1 1
2 1 2
2 1 3
I have a stored procedure that takes an XML parameter and inserts the "Entity" nodes as records into a table. This works fine unless one of the numeric fields has a value of empty string in the XML. Then it throws an "error converting data type nvarchar to numeric" error.
Is there a way for me to tell SQL to convert empty string to null for those numeric fields in the code below?
-- @importData XML <- stored procedure param
DECLARE @l_index INT
EXECUTE sp_xml_preparedocument @l_index OUTPUT, @importData
INSERT INTO dbo.myTable
(
[field1]
,[field2]
,[field3]
)
SELECT
[field1]
,[field2]
,[field3]
FROM OPENXML(@l_index, 'Entities/Entity', 1)
WITH
(
field1 int 'field1'
,field2 varchar(40) 'field2'
,field3 decimal(15, 2) 'field3'
)
EXECUTE sp_xml_removedocument @l_index
EDIT: And if it helps, sample XML. Error is thrown unless I comment out field3 in the code above or provide a value in field3 below.
<?xml version="1.0" encoding="utf-16"?>
<Entities>
<Entity>
<field1>2435</field1>
<field2>843257-3242</field2>
<field3 />
</Entity>
</Entities>
I have created a database and some dbo.tables. Now I want to create a user that are can read and write to these tables, but not modify or drop. However I want this user to be able to create own tables and let him do what he want with these.
Is this possible? Could someone explain how this can be done?
Note
I have completely re-written my original post to better explain the issue I am trying to understand. I have tried to generalise the problem as much as possible.
Also, my thanks to the original people who responded. Hopefully this post makes things a little clearer.
Context
In short, I am struggling to understand the best way to design a small scale database to handle (what I perceive to be) multiple many-to-many relationships.
Imagine the following scenario for a company organisational structure:
Textile Division Marketing Division
| |
---------------------- ----------------------
| | | |
HR Dept Finance Dept HR Dept Finance Dept
| | | |
---------- ---------- ---------- ---------
| | | | | | | |
Payroll Hiring Audit Tax Payroll Hiring Audit Accounts
| | | | | | | |
Emps Emps Emps Emps Emps Emps Emps Emps
NB: Emps denotes a list of employess that work in that area
When I first started with this issue I made four separate tables:
Divisions - Textile, Marketing (PK = DivisionID)
Departments - HR, Finance (PK = DeptID)
Functions - Payroll, Hiring, Audit, Tax, Accounts (PK = FunctionID)
Employees - List of all Employees (PK = EmployeeID)
The problem as I see it is that there are multiple many-to-many relationships i.e. many departments have many divisions and many functions have many departments.
Question
Giving the database structure above, suppose I wanted to do the following:
Get all employees who work in the Payroll function of the Marketing Division
To do this I need to be able to differentiate between the two Payroll departments but I am not sure how this can be done?
I understand that I could build a 'Link / Junction' table between Departments and Functions so that I can retrieve which Functions are in which Departments. However, I would still need to differentiate the Division they belong to.
Research Effort
As you can see I am an abecedarian when it comes to database deisgn. I have spent the last two days resaerching this issue, traversing nested set models, adjacency models, reading that this issue is known not to be NP complete etc. I am sure there is a simple solution?
Hey everyone,
Trying to work on a query that will return the top 3 selling products with the three having a distinct artist. Im getting stuck on getting the unique artist.
Simplified Table schema
Product
ProductID
Product Name
Artist Name
OrderItem
ProductID
Qty
So results would look like this...
PID artist qty
34432, 'Jimi Hendrix', 6543
54833, 'stevie ray vaughan' 2344
12344, 'carrie underwood', 1
I have a Database nearly 1.9Gb Database in size
MSDE2000 does not allow DBs that exceed 2.0Gb
I need to shrink this DB (and many like it at various client locations)
I have found and deleted many 100's of 1000's of records which are considered unneeded.
these records account for a large percentage of some of the main (largest) tables in the Database. Therefore it's reasonable to assume much space should now be retrievable.
So now I need to shrink the DB to account for the missing records
I execute "DBCC ShrinkDatabase('MyDB')"......No effect.
I have tried the various shrink facilities provided in MSSMS.... Still no effect.
I have backed up the database and restored it... Still no effect. Still 1.9Gb
Why?
Whatever procedure I eventually find needs to be replayable on a client machine with access to nothing other than OSql or similar.
Hello
I got child / parent tables as below.
MasterTable:
MasterID, Description
ChildTable
ChildID, MasterID, Description.
Using PIVOT / UNPIVOT how can i get result as below in single row.
if (MasterID : 1 got x child records)
MasterID, ChildID1, Description1, ChildID2, Description2....... ChildIDx, Descriptionx
Thanks
Hello guys...
I have a Mapserver application with SDE layers...
I´d like to know how can I edit my SDE spatial data (add/edit a point/line layer) in .NET ...
Thanks