|
You never assign any other values to it then the value in
SELECT @ParentID = ParentId FROM Parent WHERE ParentNationalNumber = @ParentNationalNumber
Is that not the correct value? If it isn't, then you must assign another value.
|
|
|
|
|
Hi all,
I m hgetting this strange message while ctreating a trigger. I can`t figure out the problem
create TRIGGER TRIG_SS_BUFFER ON INVOICE_MAIN
FOR INSERT
AS
INSERT INTO SS_BUFFER
{
SS_INV_NO,
SS_INV_USER_NO,
SS_INV_DATE,
SS_BUF_ORDER_NO,
SS_BILL_LOC_CODE,
SS_SUPP_LOC_CODE,
SS_PARTY_CODE
}
SELECT INS.INVOICE_NO, INS.INVOICE_USR_NO, INS.INVOICE_DATE, INS.INVOICE_REF_NO,
ORDER_MAIN.ORDER_BILL_LOC_CODE, ORDER_MAIN.ORDER_SUP_LOC_CODE, ORDER_MAIN.ORDER_PARTY_CODE
FROM INSERTED INS INNER JOIN
ORDER_MAIN ON INS.INVOICE_REF_NO = ORDER_MAIN.ORDER_NO
Any help would be appreciated....
When you fail to plan, you are planning to fail.
|
|
|
|
|
It was a typo. I have used '{' instead of '('. Sorry Again!!!!
When you fail to plan, you are planning to fail.
|
|
|
|
|
hai,
curretly i m using sql server 2000.
here, When i insert a record to "Table-A", an auto generated number will be stored in column "Col-AutoID" (say... 7). This 7 should be immediately stored in column "Col2-AutoID" of "Table-B".
how to proceed it with triggers?. help me. - KARAN
|
|
|
|
|
currently i m using sql server 2000.
i need a query where i would like to get the DISTINCT records from table "A" and copy to table "B".
For example...
table A consist of...
1 - testvalue
2 - testing
3 - processing
1 - testvalue
3 - processing
then the table B resultant should be of...
1 - testvalue
2 - testing
3 - processing
Since the column which going to carry the 1,2 and 3 values is PRIMARY KEY.
how to achieve it? - KARAN
|
|
|
|
|
insert into tableB select distinct col1,col2,col3 from TableA
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
|
|
|
|
|
thanks blue boy... but the thing is i m having nearly 50 columns in my table "A". I want to remove the duplicate records from table "A" (depending upon the 1st column), and insert the values in table "B" as setting the 1st column as PRIMARY KEY.......
Now, my questing is as u said...
insert into tableB select distinct col1,col2,col3... col 50 from TableA
do i want to mention all the 50 columns???????
|
|
|
|
|
So do you want distinct rows or distinct based on a specific column - if its the first then you have the answer, otherwise you are not asking the right question
Bob
Ashfield Consultants Ltd
|
|
|
|
|
How can I assign the result of a query to a variable. For example
DECLARE @FoundID VARCHAR(10)
IF NOT EXISTS(SELECT @FoundID = Employee.EmployeeID
FROM Employee
JOIN EmployeeTerritory
ON Employee.EmployeeID = EmployeeTerritory.EmployeeID
JOIN Territory
ON EmployeeTerritory.TerritoryID = Territory.TerritoryID
WHERE AssignedPostal = SUBSTRING(@CustomerPostalCode, 1, 1))
RAISERROR('The speicified CustomerPostalCode is not assigned to any salesperson! Unassigned PostalCode!', 11, 1)
So basically I want to assign Employee.EmployeeID from the query result to the variable. Most examples online show assigning result of aggregate functions to variables.
Thanks
|
|
|
|
|
CodingYoshi wrote: So basically I want to assign Employee.EmployeeID from the query result to the variable. Most examples online show assigning result of aggregate functions to variables.
If your SELECT results in only one row being returned then it should work. However, you are doing the assignment inside an IF (NOT) EXISTS which doesn't obey the normal rules of processing. It is designed to short circuit as soon as any matching data is found in order to allow the appropriate conditional statements to be run.
I would suggest moving the SELECT out of the IF condition and changing the IF condition to an ISNULL(@FoundId).
|
|
|
|
|
ISNULL(@FoundID) takes 2 parameters and when provided results in error. But this works
IF @FoundID IS NULL
RAISERROR('The speicified CustomerPostalCode is not assigned to any salesperson! Unassigned PostalCode!', 11, 1)
ELSE
SET @SalesPersonID = @FoundID
Thanks for advising to move the select statement out of if statement.
|
|
|
|
|
CodingYoshi wrote: ISNULL(@FoundID) takes 2 parameters and when provided results in error.
Ah yes... Sorry, I was going off the top of my head. Glad it still pointed you in roughly the right direction.
|
|
|
|
|
DECLARE @FoundID VARCHAR(10)
SELECT @FoundID = Employee.EmployeeID
FROM Employee
JOIN EmployeeTerritory
ON Employee.EmployeeID = EmployeeTerritory.EmployeeID
JOIN Territory
ON EmployeeTerritory.TerritoryID = Territory.TerritoryID
WHERE AssignedPostal = SUBSTRING(@CustomerPostalCode, 1, 1)
IF NOT EXISTS(@FoundID)
RAISERROR('The speicified CustomerPostalCode is not assigned to any salesperson! Unassigned PostalCode!', 11, 1)
|
|
|
|
|
NOT EXISTS(@FoundID) results in error. But this works
IF @FoundID IS NULL
RAISERROR('The speicified CustomerPostalCode is not assigned to any salesperson! Unassigned PostalCode!', 11, 1)
ELSE
SET @SalesPersonID = @FoundID
Thanks for advising to move the select statement out of if statement.
|
|
|
|
|
Could some please translate this error to human language?
I get it after I attempt to do recordset update.
What is a descriptor index and if it is invalid what is is?
Can I get more info from VC 6.0??
Thanks for reading.
Vaclav
PS Yes I did google it and came up with nothing solid.
|
|
|
|
|
I have developed a project for a tutor academy in VS2005. For data accessing I used SQL Server 2005 Express features like Data Adapter etc. Now I want to implement the data accessing through ADO.NET. Is there any conversion tool available on the internet which can translate / convert data accessing methodology of SQL Server Express to ADO.NET? If not how can I achieve it?
DotGuru
|
|
|
|
|
kashshay wrote: I used SQL Server 2005 Express features like Data Adapter etc. Now I want to implement the data accessing through ADO.NET
Data adapter is an ado.net technology, sql express has nothing to do with it. So you arr already using ado.net.
|
|
|
|
|
hi
I want to know how can i connect to other pc sqlserver with another pc
over lan connection
Thanks
|
|
|
|
|
You have to enable TCP/IP on the SQL Server. By default it is switched off. You can do this in the SQL Server Configuration Manager.
You will then be able to connect to the SQL Server from other PCs.
|
|
|
|
|
Yo can use UDL file [^]too.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
|
|
|
|
|
Hi,
I am using SQL Server 2005. When I create an index on a foreign key there is an option to check the "Use Page Locks when Accessing the Index" option. I do not know when to check this and when not to?
Can someone please help clear this for me? If checked will it reduce performance, or is it standard procedure to always have it checked?
Thanks
Brendan
|
|
|
|
|
i want to spilit the date on format dd/mm/yyyy and insert the substring as primary key field on another table
i tried the following but it failed
declare @exitDate smalldatetime
set @exitdate=(select Exit_date from invoice_details)
select substring( cast (@exitDate As varchar) As exitDateText,5,4)
from invoice_details
help please
regards
|
|
|
|
|
I'm guessing, because you didn't explain (you just supplied some broken code and said it didn't work) that you want to extract the year. Is that correct?
If so, why not just use the YEAR(@someDate) function? You can then cast that into a varchar.
|
|
|
|
|
Hi,
I'm using SQL Server 2000 with VB.NET 2005.
I'm trying to access the database which is in remote machine thru internet.
Can you help me with the required details & connection string...
Thanks & Regards.
Hariram
|
|
|
|
|
The connection string will be as normal, but with the IP address or full domain name as the server name.
|
|
|
|