Hi,
I have table Cars
Id nvarchar(25) PK
Name nvarchar(max)
And there is some records.
Id Name
CodeXYZ Namezxc
CodeQAZ Nameasd
CodeEDC Nameqwe
I want to convert Id column to int autoincrement:
Id Name
1 Namezxc
2 Nameasd
3 Nameqwe
but I have no idea how to make it :/
Could you help me ?
...
I use Hibernate in a storefinder application.
For the proximity search in SQL I use the haversine formula. Because this is a bit messy SQL I created a named SQL query in my .hbm.xml File for this.
SELECT
location.*,
( 3959 * acos( cos( radians(7.4481481) ) *
cos( radians( X(location.coordinates) ) ) *
cos( radians( ...
Both of these work individually
SELECT PONumber,
count(RequestNumber) as "InNumOfRequests",
sum(Amount) as "SumofAmounts"
FROM tableView
GROUP BY PONumber
SELECT DISTINCT PONumber,
(10 * ceiling((DATEDIFF(day,POApprovedDate,GETDATE()))/10))
AS "BINofDaysSincePOApproved" ...
I'm creating an auditting table, and I have the easy Insert and Delete auditting methods done. I'm a bit stuck on the Update method - I need to be able to get the current values in the database, the new values in the query parameters, and compare the two so I can input the old values and changed values into a table in the database.
Here...
Hi all,
I searched a lot, but couldn't find anything.. I just want to ask if there's any way to create and call a procedure (Informix) with out parameters. I know how to return one or more values (for procedures and for functions), but this is not what I want. It would be really strange, if Informix does not allow output parameters..
...
Hello,
I have a T-Sql Statement as follows;
Insert into Table1
Select * From Table2
I want to know the running sequence. Does the insert waits select statement to finish before starting or it starts asap select statement starts returning values and expects new records from the select statement to continue.
This is a plain stored pr...
Let´s say I have one table called ProjectTimeSpan (which I haven´t, just as example!) containing the columns StartDate and EndDate.
And that I have another table called SubProjectTimeSpan, also containing columns called StartDate and EndDate, where I would like to set a Check constraint that makes it impossible to set StartDate and EndD...
I'm trying to import my CSV data file back into my database in the same order it is in the CSv file. However when I import the order is all jumbled from how it appears in the file.
Is there a way to force PHPmyadmin to import in the exact same order as the CSV?
...
Using ASP MVC with active record.
Ive got 2 tables with records that sometimes are related and sometimes aren't. The relation is defined by the user. 1 table has projects, the other has devices. Projects can be created and deleted, devices cannot. When a user deletes a project, all relations between that project and the devices should b...
in the databse i have the format of the date like 'yyyy-mm-dd'.
how can i fetch the current date in this format? and then if i want to calculate the date after 1 week how can i do that.
thanxx in advance.
Using php and mysql.
...
Hi All,
I have to get totals from a table using different criteria, which I do like this:
SELECT DISTINCT
SUM(CASE WHEN MYCONDITION1 THEN 1 ELSE 0 END) AS TOTAL1,
SUM(CASE WHEN MYCONDITION2 THEN 1 ELSE 0 END) AS TOTAL2
FROM TABLE1, TABLE2
WHERE COMMON_CONDITION1 AND COMMON_CONDITION2
AND BETWEEN DATE1 AND DATE2;
This works fine an...
I have a C# data structure which consists of classes and collections which have references to each other. Currently I am using Serialization to store the structure in XML, which works as a handy way to save/load the structure into my application.
If I want to be able to save/load the structure into a database, is there a simple way? Sho...
Hallo all,
I have a problem to introduce a good versioning in my database design.
Let's make a easy example. A little rental service.
You have a table Person (P_ID, Name), table Computer (C_ID, Type) and a table Rent (R_ID, P_ID, C_ID, FromData, ToData).
I want to be able to change say the user name, create a new version and still ha...
I want script to convert my table
CREATE TABLE #TempTable (
Code nvarchar(5) primary key,
name nvarchar(100) )
Insert into #TempTable (Code ,name)
Select st.Code , st.name From StaticTable st
But there is something I must change.
Code must be autoincremented from 100
Where length of code is more than 3, then I want insert there i...
In SQL, one should always strive for set-based operations versus iteration-based (i.e. looping). In .NET, we frequently loop collections and objects. Are there any commands in .NET that allow set-based processing or is everything iteration-based? (I'm reminded of how DataAdapter.Fill calls DataReader which iterates through each record in...
I'm trying to document some SQL and wanted to get the right terminology. If you write SQL like so;
select child.ID, parent.ID
from hierarchy child
inner join hierarchy parent
on child.parentId = parent.ID
Then you have one actual table ('hierarchy') which you are giving two names ('parent' and 'child') My question is about how you r...
I have two tables in my Database.This can increase later on.I want to add another table Audit to track changes to the existing two tables.I want to track any change done to any of these table
AUdit Table structure is
ID
Table_Name
Field_Name
Old_Value
New_Value
Modified_By
Date_of_Modification
SO now I want to have one trigger for bot...
IHello,
I'm trying to count for each table in my MySQL database how many records there are in it.
All of my tables happen to be in InnoDB and this query
SELECT TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'myschema';
is way much too much of an estimate (There are +846 records and it tells me there are only +-400)
...
Hi All
I have the following stored procedure:
ALTER Procedure dbo.APPL_ServerEnvironmentInsert
(
@ServerEnvironmentName varchar(50),
@ServerEnvironmentDescription varchar(1000),
@UserCreatedId uniqueidentifier,
@ServerEnvironmentId uniqueidentifier OUTPUT
)
WITH RECOMPILE
AS
-- Stores the ServerEnvironmentId.
DE...
hello my friends,
thanks for your attention to answer the questions.
How can I merge two tables from different databases?
Thanks again
...