|
Maybe something like:
SELECT DISTINCT * FROM YourTable WHERE Tic_Denom_No=5 AND (Tic_start_no > 111112411 AND Tic_end_no < 111112710)
Or something along those lines...
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi,
I have a web site that the DB of it (SQL Server) is created on host but its tables is empty.
I populate tables Locally and now I want to transfer the records from local (My Computer) to Server.
The host don't permit for restore and attach, and if I develope an application for transfering data, a problem occures:
Spot this table(on local):
ID Name
--- -------
1 John
2 Merry
4 Simon
that ID Field, its identity is 'yes'. Now if I want to insert this in server 'simon' gives '3' ID, And this table have relation with other table on 'ID' field?
what should I do?
Best wishes
|
|
|
|
|
You need to disable foreign key constraints (and triggers if needed) before inserting. For SQL Server 2005 this is:
Disable all Constraints:
ALTER TABLE YourTable NOCHECK CONSTRAINT ALL
Disable all Triggers on a table
DISABLE Trigger ALL ON YourTable
Make sure to turn them back on when you are done.
Pete Soheil
DigiOz Multimedia
http://www.digioz.com
|
|
|
|
|
hi there,
I have a form in which there are three options for phone numbers ie cellphone, office phone and residence phone. The condition is the user is supposed to enter at least one number. My problem is i need to display the details of all the registered candidates in a gridview which has only one column named phone. i dnt knw how to write the query to check which phone number is entered by each candidate and display it. The priority between the phone numbers is given as office phone,cell phone then residence phone
Do anyone have a solution for this????? 
|
|
|
|
|
You haven't stated what database you are using. However, if you are using SQL Server then you can use the COALESCE function. COALESCE returns the first non-null value in a series of values. It checks these values from l-r, so you can define an order of precedence. See the following example:
SELECT COALESCE([office], [cell], [residence]) AS Phone FROM MyTable
Hope this helps.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi i have an access db where i have a check box for new items on the list,
I want to un-check it after viewing that item through my web application.
How do u set a check box to unchecked?
New? is the name of the column where i have the checkboxes.
i thought its like this;
string sql = "INSERT into ([New?])" + " VALUES ( '" + false +"')";
but this doesnt work
thanks
|
|
|
|
|
s3rro wrote: string sql = "INSERT into ([New?])" + " VALUES ( '" + false +"')";
Your query should work if you remove the quotes surrounding the literal value false.
BTW, it's actually a Boolean field. The check boxes are just a presentation feature provided by Access when viewing the contents of the table.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
This query won't update anything. It's an INSERT query, which means it creates new records.
There is also no WHERE clause, so even if you changes the INSERT to UPDATE, it would change ALL of the records in the table, not just the ones that have their [New?] field set to True.
You also don't specify which table your making an update to.
Your column name is also pretty bad. Don't use punctuation marks in table or column names. This will make for some very interesting debugging sessions if you do.
I think your query, assuming you want to change all the records that are tagged "new" to false and your [New?] column is of type "Yes/No", should look something like this:
UPDATE tableName
SET [New?] = False
WHERE [New?] = True
|
|
|
|
|
I don't know which version of Access you are using but in 97 and 2000 I believe true is -1 and false is 0.
So if all else fails with updating the database give these values a go.
Regards
Guy
P.S. Can anyone explain to me why M$ set true to -1 and not 1?
You always pass failure on the way to success.
|
|
|
|
|
I have a table Task which has the primary key as TaskID and a projectID.
I have another Table called Successors which has two fields TaskID and SuccessorID which are both forigen keys from Task.TaskID
What I need to do is create a statement so that All Tasks where proeject ID = X, are deleted if their Task ID is not found in any of the records in the successor table.
Anyone have any ideas?
|
|
|
|
|
This should get you started.
DELETE FROM
Task
WHERE
ProjectID NOT IN (SELECT
ProjectID
FROM
Task t
INNER JOIN
Successor s
ON (t.TaskID = s.TaskID))
|
|
|
|
|
I am generating bulk invoices using front end and when I try to insert it to the data base it takes hours it’s unacceptable.
This is how I am doing the task
Get relevant Cx accounts to data tables
Generates Invoice header and detail records and store those records on Invoice Header and Detail Data tables
Loop the invoice header data table and Insert recodes using Strode procedure.
Loop the invoice detail data table and Insert recodes using Strode procedure.
To generate for 200000 invoices it takes more than 24 Hrs.
How can I improve the performance?
Please refer the code.
//Inserting the Invoice Header records
foreach(DataRow InvHDR in DS_BillData.Tables["InvoiceHeaderInformation"].Rows)
{
SqlParameter[] para =new SqlParameter[14];
para[0]=new SqlParameter("@GUAccountID",InvHDR["GUAccountID"]);
para[1]=new SqlParameter("@GUInvID",InvHDR["GUInvoiceID"]);
para[2]=new SqlParameter("@InvoiceNo",InvHDR["InvoiceNo"]);
para[3]=new SqlParameter("@InvoiceDate",StartDate);
para[4]=new SqlParameter("@DueDate",DueDate);
para[5]=new SqlParameter("@BatchNo",BatchID);
para[6]=new SqlParameter("@GUStatmentID",InvHDR["GUInvoiceID"]);
para[7]=new SqlParameter("@BatchSNCount",BatchSNCount);
para[8]=new SqlParameter("@PAYMENTRECIVED",InvHDR["PAYMENTRECIVED"]);
para[9]=new SqlParameter("@SubTotal",InvHDR["SubTotal"]);
para[10]=new SqlParameter("@InvoiceAmount",InvHDR["InvoiceAmount"]);
para[11]=new SqlParameter("@VAT",InvHDR["VAT"]);
para[12]=new SqlParameter("@OtherTax",InvHDR["OtherTax"]);
para[13]=new SqlParameter("@StatmentNo",InvHDR["InvoiceNo"]);
//para[13]=new SqlParameter("@WaveOFF","Y");
callSp("BillingInvoiceCreation_forFront",para);
}
Stored Procedure---
Procedure BillingInvoiceCreation_forFront
(
@GUAccountID as nvarchar(30),
@GUInvID as nvarchar(30),
@InvoiceNo as numeric,
@InvoiceDate as datetime,
@DueDate as datetime,
@BatchNo as Decimal,
@GUStatmentID as nvarchar(30),
@StatmentNo as numeric,
@BatchSNCount as decimal,
@PAYMENTRECIVED as decimal(9,2),
@SubTotal as decimal(9,2),
@InvoiceAmount as decimal(9,2),
@VAT as decimal(9,2),
@OtherTax as decimal(9,2)
)
as
BEGIN
Declare @PrintDescription as nvarchar(100)
Declare @GUItemID as nvarchar(30)
Declare @PaymentAmt as decimal(9,2)
Declare @DueAmount as decimal(9,2)
Declare @CreditNoteAmount as decimal(9,2)
Declare @BFAmount as decimal(9,2)
INSERT INTO B_BillingInvoiceHeader(StatementNo, GUStatementID, GUInvID,
CompanyID, LocationID, BranchID, DeptID, InvoiceNo,
InvoiceDate, DueDate, Status, GUAccountID, ManualInvoice,
BatchNo, InvoiceType,BatchSNCount,BillingYear,BillingMonth,SubTotal,InvoiceAmount,VAT,OtherTax)
VALUES(@StatmentNo, @GUStatmentID, @GUInvID,
1, 1, 1, 1, @InvoiceNo,
@InvoiceDate, @DueDate, 'New', @GUAccountID, 'N',
@BatchNo, 'Batch',@BatchSNCount,year(@InvoiceDate),month(@InvoiceDate),@SubTotal,@InvoiceAmount,@VAT,@OtherTax)
SELECT @BFAmount=isnull(SUM(InvoiceAmount - PaidAmount),0)
FROM B_BillingInvoiceHeader
WHERE (GUAccountID = @GUAccountID) AND (PaymentCompleted = N'N') AND BatchNo<@BatchNo
/*_________________ Add Sanka ______________________*/
exec BillingCustomerAdvances @GUInvID
--- Late Invoice Delocate-----------------------------------------------------------------<<(*_*)>>-----
SELECT @PaymentAmt = PaymentReceve From B_CustomerPaymentRec Where GUAccountID=@GUAccountID And BatchNo=@BatchNo
SELECT @CreditNoteAmount=isnull(SUM(Amount) ,0)
FROM B_CreditNote
WHERE (Status='APPROVED') And (Completed ='N') AND (GUAccountID = @GUAccountID)
INSERT INTO B_MonthlyOpenningBalance
(GuAccountID, BatchNo, OppenningBalance, ClosingBalance, CreditNote, AdvanceBalance, UtilizedCredits)
VALUES (@GuAccountID, @BatchNo, @BFAmount, @BFAmount+@InvoiceAmount, @CreditNoteAmount, 0, 0)
INSERT INTO B_MonthlyBF
(CompanyID, LocationID, BranchID, DeptID, BatchNo, BFAmount, GUAccountID)
VALUES (1, 1, 1, 1, @BatchNo, @BFAmount, @GUAccountID)
Update B_CreditNote Set Completed ='Y' WHERE (Status='APPROVED') And (Completed ='N') AND (GUAccountID = @GUAccountID)
END
------
Thanks for the help i am working on DTS update method con any one give me a direction or small sample code kind of a thing?
Regards,
Daminda.
modified on Friday, December 21, 2007 9:30:11 AM
|
|
|
|
|
You should examine the execution plans for your queries and use the Profiler tool to identify the bottlenecks in your code.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Have you considered using something like DTS or SSIS instead. They are set up to bulk load data.
|
|
|
|
|
Hi I wish to create a custom auto generate ID, such as P110, P111 which is generated automatically is there ways to set it in sql server?Thanks alot
|
|
|
|
|
You can set an int column to be an IDENTITY field to generate sequential numbers in that field. If you want your sequence to be alphanumeric, you should create a computed column for that purpose.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi
can any one knows how to establish database connection with java script
thanks in advance
|
|
|
|
|
rajesh4u wrote: can any one knows how to establish database connection with java script
You could use "Astoria" - now known as ADO.NET data services: Astoria website[^]
|
|
|
|
|
You can do it using Ajax only.
If u r using VS 2005, u can use the Ajax control toolkit for this purpose
|
|
|
|
|
Hi,
I created a SQL Linked server for excel file. I am using that Linked server to Import the data from Excel files.When selecting the reords from this linked server , it returns the data in alphabetical order.
But I want the same order of columns which is in Excel file.
for selecting the records i am using tis Query:
select * from ExcelImport...Test$
where, ExcelImport is Linked server name and Test$ is the sheet in the excel file.
Please help.
kalam.
|
|
|
|
|
Can you not provide the named columns in the select statement:
e.g. Select cola, othercolumnname from excelimport
|
|
|
|
|
hi,
I need to login to remote sql server trough my Application and need to change the server location
|
|
|
|
|
Is there a problem you are having? Your post is too vague.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
i need a query for checkin a name whether it exists or not in database,,
am storing firstname nd lastname in seperate columns.
bt if i enter a first name only in textbox i need to display all names(firstname+lastname) ,starting from the entered first name
PLZ HELP...
Waiting 4 reply...
|
|
|
|
|
Hi Mithun,
Please try this. Hope it will help you.
if exists(select ID from Tablename where nameFirst like '%Your TextBox Value%')<br />
<br />
select nameFirst + SPACE(1) + nameLast As Name from Tablename where nameFirst like '%Your TextBox Value%'
Keep Smiling
|
|
|
|
|