Instead Of Trigger And In-Place Updates
Sep 18, 2007
Converting an existing application, I have a table:
create table problem
(
building char(3),
function char(4),
sqft int,
pct dec(5,2)
)
[pct] is a problem because it depends on it's own row and the sum of all other rows for the same building:
pct = sqft / sum(sqft) over building
I want to create a trigger to update the pct column in the database instead of any business layer. But, because it's updating itself I will use an Instead Of trigger that is separate from the table's Insert & Delete triggers.
The table has a primary key defined such that 'In-Place' updates will be used, that was a technique for reducing disk activity way back when and I can find no reference to it in SQL2005 BOL.
My question is, does the 'Inserted' table still exist for 'In-Place' updates? Or more basically, does the In-Place update still exist?
Thanks.
View 3 Replies
ADVERTISEMENT
Dec 19, 2007
I have a project that consists of a SQL db with an Access front end as the user interface. Here is the structure of the table on which this question is based:
Code Block
create table #IncomeAndExpenseData (
recordID nvarchar(5)NOT NULL,
itemID int NOT NULL,
itemvalue decimal(18, 2) NULL,
monthitemvalue decimal(18, 2) NULL
)
The itemvalue field is where the user enters his/her numbers via Access. There is an IncomeAndExpenseCodes table as well which holds item information, including the itemID and entry unit of measure. Some itemIDs have an entry unit of measure of $/mo, while others are entered in terms of $/yr, others in %/yr.
For itemvalues of itemIDs with entry units of measure that are not $/mo a stored procedure performs calculations which converts them into numbers that has a unit of measure of $/mo and updates IncomeAndExpenseData putting these numbers in the monthitemvalue field. This stored procedure is written to only calculate values for monthitemvalue fields which are null in order to avoid recalculating every single row in the table.
If the user edits the itemvalue field there is a trigger on IncomeAndExpenseData which sets the monthitemvalue to null so the stored procedure recalculates the monthitemvalue for the changed rows. However, it appears this trigger is also setting monthitemvalue to null after the stored procedure updates the IncomeAndExpenseData table with the recalculated monthitemvalues, thus wiping out the answers.
How do I write a trigger that sets the monthitemvalue to null only when the user edits the itemvalue field, not when the stored procedure puts the recalculated monthitemvalue into the IncomeAndExpenseData table?
View 4 Replies
View Related
Jan 12, 2004
I've a system of users and let's call em subusers. Every User becomes an automatic generated login when entered into the database. Every subuser has a reference to his user and no login, cause only thr root in the chain is able to login. But when the user gets deleted, all subusers become a new user. I've done this with a trigger changing the superUser Value=0:
create trigger abc on Users AFTER DELETE
as
declare @h int
SELECT @h = id FOM inserted
UPDATE Users SET superUser=0 WHERE superUser=@h
Furthermore the trigger deletes all additionally data of the user.
Since every subuser of the deleted user becomes a user himself for every subuser a new Login must be created. I'm using an update triger for this task:
1: create trigger userUpdate on Users After Update
2: AS
3: DECLARE @superold int
4: @supernew int
5: @name nvarchar(55)
6: @date smalldatetime
7: if UPDATE(superUser)
8: begin
9: SELECT @superold= superUser FROM deleted
10: SELECT @supernew=superUser FROM inserted
11:
12: if @superold <> @supernew
13: begin
14: if @superold = 0
15: begin
16: DELETE FROM UserLogin WHERE id=@superold
17: end
18: else if @supernew=0
19: begin
20: SELECT @name=Name,@date=Date from inserted
21: execute createLogin @supernew,@name,@date
21: end
22: end
23: end
The problem is in line 20 and 21, cause the values @name and @date containing only the last updated user(the last entry in the inserted table) thus only for the last user a new Login is created whereas the others become the state user but no login was created. What i need is a method to loop over all entrys in the tables inserted btw. deleted.
Does anybody know how to achieve this, looping the tables and executing a stored procedure for every entry?
bye
View 10 Replies
View Related
Mar 2, 2006
I am trying to implement trigger which can handle multirow updates and which is running on replicated table. So I want it never fails as trigger failure brakes replication.
So:
CREATE TRIGGER on_person_update
BEGIN
-- create temp table
-- populate temp table with Inserted values (I do not need Deleted as PK never change)
COMMIT TRAN
-- Am I right that this insures updates on replicated table will never be rollback after this commit?
BEGIN TRAN A
-- Make a checkpoint here to be able to rollback at any time to this point if something wrong inside loop.
SAVE TRAN MyTran
-- Start looping in temp table
-- RUN DML statement to make neccesary changes for each record in temp table
-- Does it make any sense to do this (IF @ERR below)? When I am trying in DML insert string value into integer column it never gets to IF statement - terminates straight away.
-- Reason why I think I need it as this trigger might be called by another trigger and top level trigger will get an error and can make a decision based on this.
IF @ERR <> 0
BEGIN
ROLLBACK TRAN MyTran
RAISERROR('Insert or Update failed in on_person_sls_update trigger with error: %s', 16, 1, @ERR)
RETURN
END
-- End looping temp
-- Do I need here COMMIT TRAN A or trigger will make commit anyway?
END
Why all of this?
Data changed on distributor and arrive to subscriber as a transaction.
We have a trigger on replicated table which will update replicated table in any way but after that it will update another database on subscriber.
This trigger should be able to handle multirow updates.
When this trigger updates another database it runs DML which fires other triggers so they become nested, if I am right. Our trigger should always accept changes from distributor as if it fails replication brakes but after data saved in temp table none or all changes have to be made.
May be I am copmpletely wrong with this template - hope somebody will help.
Thank you,
Igor
View 2 Replies
View Related
Apr 21, 2004
Hey, I have couple of triggers to one of the tables. It is failing if I update multiple records at the same time from the stored procedure.
UPDATE
table1
SET
col1 = 0
WHERE col2 between 10 and 20
Error I am getting is :
Server: Msg 512, Level 16, State 1, Procedure t_thickupdate, Line 12
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.
What is the best possible way to make it work? Thank you.
View 7 Replies
View Related
May 5, 2008
Hi,
Does anyone know if there's a way to log batch updates done using SQL queries without using a trigger or a cursor?
Thanks in advance,
Vinod
View 6 Replies
View Related
Dec 28, 2007
I was able to catch one update but not multiple updates or batch updates done to the table. I know the updated records are residing in inserted and deleted tables. Without using cursors, how can i read and compare all the rows in these two tables?
Following is the table structure:
Customer_Master(custmastercode, customer_company_name,updated_by)
Following is the trigger:
ALTER TRIGGER [TR_UPDATE_CUST]
ON [dbo].[CUSTOMER_MASTER]
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;
IF EXISTS (SELECT * FROM inserted)
BEGIN
declare @custcode int
Declare @message varchar(5000)
Declare @custommessage varchar(2000)
Declare @CUSTMASTERCODE int
Declare @CUSTOMER_COMPANY_NAME varchar(50)
Set @message = 'Changes in customer account number ' + Cast ((@custcode) as varchar(10)) + ': '
select @custcode = [CUSTMASTERCODE],@UPDATED_BY = [UPDATED_BY] from inserted
Set @message = 'Changes in customer account number ' + Cast ((@custcode) as varchar(10)) + ': '
IF(update([CUSTOMER_COMPANY_NAME]))
Begin
select @UCUSTOMER_COMPANY_NAME = [CUSTOMER_COMPANY_NAME] from deleted
select @CUSTOMER_COMPANY_NAME = [CUSTOMER_COMPANY_NAME] from inserted
Set @custommessage = 'Customer company name changed from ' + @UCUSTOMER_COMPANY_NAME + ' to ' + @CUSTOMER_COMPANY_NAME + '.'
Set @message = @message + @custommessage
End
Set @message = @message + ' Updated by ' + @UPDATED_BY + ' at ' + CAST(getdate() AS VARCHAR(20))+ '.'
INSERT INTO [CHANGE_HISTORY]
([CUSTMASTERCODE]
,[CHANGE_DETAILS])
VALUES (@custcode, @message)
END
END
View 7 Replies
View Related
Mar 9, 2015
I am looking to update a record from a previous row. So if there is a value of total goods in week 1, i want that value to carry forward to the value of goods in week 2. Is there any SQL as an example of the best way to accomplish this? I can query it using lag() which works great but i need the source data itself to update as the end-users are accessing the data via lightswitch, so when they save a change, i want the trigger (or whatever you recommend) to update the source table.
View 9 Replies
View Related
Jul 20, 2007
Is there a place where i can find events that takes place in the sql server? Like adding data to a database or something like that....
Regards
Karen
View 4 Replies
View Related
Oct 30, 2007
Hi...
I have data that i am getting through a dbf file. and i am dumping that data to a sql server... and then taking the data from the sql server after scrubing it i put it into the production database.. right my stored procedure handles a single plan only... but now there may be two or more plans together in the same sql server database which i need to scrub and then update that particular plan already exists or inserts if they dont...
this is my sproc...
ALTER PROCEDURE [dbo].[usp_Import_Plan]
@ClientId int,
@UserId int = NULL,
@HistoryId int,
@ShowStatus bit = 0-- Indicates whether status messages should be returned during the import.
AS
SET NOCOUNT ON
DECLARE
@Count int,
@Sproc varchar(50),
@Status varchar(200),
@TotalCount int
SET @Sproc = OBJECT_NAME(@@ProcId)
SET @Status = 'Updating plan information in Plan table.'
UPDATE
Statements..Plan
SET
PlanName = PlanName1,
Description = PlanName2
FROM
Statements..Plan cp
JOIN (
SELECT DISTINCT
PlanId,
PlanName1,
PlanName2
FROM
Census
) c
ON cp.CPlanId = c.PlanId
WHERE
cp.ClientId = @ClientId
AND
(
IsNull(cp.PlanName,'') <> IsNull(c.PlanName1,'')
OR
IsNull(cp.Description,'') <> IsNull(c.PlanName2,'')
)
SET @Count = @@ROWCOUNT
IF @Count > 0
BEGIN
SET @Status = 'Updated ' + Cast(@Count AS varchar(10)) + ' record(s) in ClientPlan.'
END
ELSE
BEGIN
SET @Status = 'No records were updated in Plan.'
END
SET @Status = 'Adding plan information to Plan table.'
INSERT INTO Statements..Plan (
ClientId,
ClientPlanId,
UserId,
PlanName,
Description
)
SELECT DISTINCT
@ClientId,
CPlanId,
@UserId,
PlanName1,
PlanName2
FROM
Census
WHERE
PlanId NOT IN (
SELECT DISTINCT
CPlanId
FROM
Statements..Plan
WHERE
ClientId = @ClientId
AND
ClientPlanId IS NOT NULL
)
SET @Count = @@ROWCOUNT
IF @Count > 0
BEGIN
SET @Status = 'Added ' + Cast(@Count AS varchar(10)) + ' record(s) to Plan.'
END
ELSE
BEGIN
SET @Status = 'No information was added Plan.'
END
SET NOCOUNT OFF
So how do i do multiple inserts and updates using this stored procedure...
Regards
Karen
View 5 Replies
View Related
Nov 16, 2001
Hi,
Can anyone give me any input on this. Recently TempDB one of my production server came down because tempDB got so big that it chewed up all the space in it's drive. My TempDB was in drive C:, where the Operating system and the rest of the SQL systems databases are(msdb,model,master). The actual production data are located in another logical RAID 5(Drive E:) Drive. I want to prevent the problem from happening again. Is it wise or does it degrade performance if i move TEMPDB from drive C: to drive E:? Is this going to cause a major bottom neck in drive E:, where the data are located?
Thank You for any help!
Eric
View 1 Replies
View Related
Jan 5, 2006
what happens if the physical location of a box(which had sql server 2000 on it) is chaned.
what happens to the replication and distributed queries.
Thanks.
View 1 Replies
View Related
May 20, 2004
I have one big db and i heve no place on disk
the log file is big too. how can i delete the log
View 7 Replies
View Related
Apr 17, 2007
I am fairly versed with SQL 2005 as I have been using it since it came out. Now I have need to learn about Cubes.
Does anybody have any suggestions of where I need to begin to learn about what cubes are, how to create them and use them?
Ultimately we will be incorporating them into Reporting Services.
Thanks for the information.
View 3 Replies
View Related
Dec 26, 2007
Where would i place an orderby my DateCreated field...everywhere i try to place it i get this error...
The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified. Any help with this issue would be greatly appreciated....
CREATE PROCEDURE GetTimeCard
( @LoginID nvarchar(50),
@DateRangeFrom datetime,
@DateRangeTo datetime
)
AS
BEGIN
IF ( @DateRangeFrom = '1/1/1753' ) AND ( @DateRangeTo = '1/1/1753' )
select x.*, x1.TotalExpenses, x2.WorkedCount
from (
select tc.TimeCardID, tc.DateCreated,tc.DateEntered, oe.FirstName, oe.LastName
from OPS_TimeCards tc
join OPS_TimeCardExpenses tce on tc.TimeCardID = tce.TimeCardID
join OPS_Employees oe on oe.EmployeeID = tc.EmployeeID
where oe.LoginID = @LoginID
group by tc.TimeCardID, tc.DateCreated,tc.DateEntered, oe.FirstName, oe.LastName
union
select tc.TimeCardID, tc.DateCreated,tc.DateEntered,oe.FirstName, oe.LastName
from OPS_TimeCards tc
join OPS_TimeCardHours tce on tc.TimeCardID = tce.TimeCardID
join OPS_Employees oe on oe.EmployeeID = tc.EmployeeID
where oe.LoginID = @LoginID
group by tc.TimeCardID, tc.DateCreated ,oe.FirstName,tc.DateEntered, oe.LastName ) x
left outer join (
select tc.TimeCardID, tc.DateCreated,tc.DateEntered, sum(tce.ExpenseAmount) as TotalExpenses
from OPS_TimeCards tc
join OPS_TimeCardExpenses tce on tc.TimeCardID = tce.TimeCardID
join OPS_Employees oe on oe.EmployeeID = tc.EmployeeID
where oe.LoginID = @LoginID
group by tc.TimeCardID, tc.DateCreated,tc.DateEntered ) x1 on x1.TimeCardID = x.TimeCardID and x1.DateCreated = x.DateCreated and x1.DateEntered = x.DateEntered
left outer join (
select tc.TimeCardID, tc.DateCreated,tc.DateEntered, count(*) WorkedCount
from OPS_TimeCards tc
join OPS_TimeCardHours tce on tc.TimeCardID = tce.TimeCardID
join OPS_Employees oe on oe.EmployeeID = tc.EmployeeID
where oe.LoginID = @LoginID
group by tc.TimeCardID, tc.DateCreated, tc.DateEntered) x2 on x2.TimeCardID = x.TimeCardID and x2.DateCreated = x.DateCreated and x2.DateEntered = x.DateEntered
ELSE
select x.*, x1.TotalExpenses, x2.WorkedCount
from (
select tc.TimeCardID, tc.DateCreated,tc.DateEntered, oe.FirstName, oe.LastName
from OPS_TimeCards tc
join OPS_TimeCardExpenses tce on tc.TimeCardID = tce.TimeCardID
join OPS_Employees oe on oe.EmployeeID = tc.EmployeeID
where oe.LoginID = @LoginID And tc.DateCreated BETWEEN @DateRangeFrom AND @DateRangeTo
group by tc.TimeCardID, tc.DateCreated,tc.DateEntered, oe.FirstName, oe.LastName
union
select tc.TimeCardID, tc.DateCreated,tc.DateEntered,oe.FirstName, oe.LastName
from OPS_TimeCards tc
join OPS_TimeCardHours tce on tc.TimeCardID = tce.TimeCardID
join OPS_Employees oe on oe.EmployeeID = tc.EmployeeID
where oe.LoginID = @LoginID And tc.DateCreated BETWEEN @DateRangeFrom AND @DateRangeTo
group by tc.TimeCardID, tc.DateCreated ,oe.FirstName,tc.DateEntered, oe.LastName ) x
left outer join (
select tc.TimeCardID, tc.DateCreated,tc.DateEntered, sum(tce.ExpenseAmount) as TotalExpenses
from OPS_TimeCards tc
join OPS_TimeCardExpenses tce on tc.TimeCardID = tce.TimeCardID
join OPS_Employees oe on oe.EmployeeID = tc.EmployeeID
where oe.LoginID = @LoginID
group by tc.TimeCardID, tc.DateCreated,tc.DateEntered ) x1 on x1.TimeCardID = x.TimeCardID and x1.DateCreated = x.DateCreated and x1.DateEntered = x.DateEntered
left outer join (
select tc.TimeCardID, tc.DateCreated,tc.DateEntered, count(*) WorkedCount
from OPS_TimeCards tc
join OPS_TimeCardHours tce on tc.TimeCardID = tce.TimeCardID
join OPS_Employees oe on oe.EmployeeID = tc.EmployeeID
where oe.LoginID = @LoginID
group by tc.TimeCardID, tc.DateCreated, tc.DateEntered) x2 on x2.TimeCardID = x.TimeCardID and x2.DateCreated = x.DateCreated and x2.DateEntered = x.DateEntered
End
GO
View 3 Replies
View Related
May 30, 2006
I have a design that includes articles that will be searched. Obviously its too slow to put them into fields, and impossible because some have photos or are otherwise html documents. So I want to put pointers to their location.
Two questions. For each deployment, both desktop and web, where is the best place to put the articles. In any folder, or only in an iis virtual folder?
dennist685
View 5 Replies
View Related
Jan 28, 2004
I'm rapidly understanding that much more of my application as a whole is in SQL Server that I would have originally thought.
Stored Procedures
Triggers
Constrains
And so on
It generally means that some of the stuff I'd have naturally done in the Business Layer might be best done in SQL - certain issues in the Business Layer might be best being triggers or constraints for example...
One thing that still puzzles me, and I'd like some references or advice now as it's a blank area in my mind is how this interfaces to your asp.net code.
Obviously I call stored procedures and the like from code, and use parameters, etc, not problem, it's more what I do when these stored procedures or associated triggers fail (or a constrain fails - though this should be less likely)?
SQL sends back an error? But what? Then what do you get your page to do, especially if SQL failed midway through a 'big' transaction? Do you have save 'where the user was somehow' so they don't start inputting again?
It's all a bit vague at the moment, some detail would be nice? :)
View 4 Replies
View Related
Nov 12, 2005
Hello all,I have an SQL query which retrieves a COUNT number from 2 different tables, and i want to do a division with botht he COUNT data retrieved. Trouble is I can't get it in the format that I want, my SQL query is as below :-SELECT ROUND( ((T1.Present/T2.Total ) * 100), 2) FROM(Select Count(Date) as Present from Attendance WHERE Month(Date)=12 AND Status=1) T1,(Select Count(Date) as Total from Attendance WHERE Month(Date)=12) T2The trouble here is that the result should be as below: T1.Present = 3T2.Total = 5 T1.Present/T2.Total = 3/5 = 0.6The final should be 60 after divided by 100But i am getting a zero as my result, even when I don't multiply the number by 100, the division result is still zero. I am guessing it is a conversion problem. Could anyone please offer me any advise on how to get the final result in the format I want?
View 2 Replies
View Related
Dec 14, 2001
Hi, I want to replace the indexes in my database to a different
filegroup. How can I do that using T-SQL? I only found a way that
uses the EM, but I have a lot of indexes and I hate to do it manually.
Thanks a lot.
View 2 Replies
View Related
Aug 9, 2001
One of our customers has a production and a test database. We are loading tables via a C++ program that works on production, but not on test, which is supposed to be an exact duplicate.
The error we are getting when trying to add columns to one of the table is 80004e21 null That is it.
When we load the exact same records in the production environment we do not get the error. We have spent many hours ensuring that the tables are exactly the same on test as in production.
Does anyone know, is there an environment variable at a database level that says how to handle null values?
Thanks!!!
C
View 1 Replies
View Related
Feb 4, 2000
If I have a publisher, distributor, and subscribers all running SQL 6.5, and I wish to upgrade to SQL 7.0, in what order to I upgrade?
View 1 Replies
View Related
Mar 11, 2004
Hi All!
I know that if is want to backup my db on the c: drive i do this
BACKUP DATABASE DBName
TO DISK = 'c:isl_fs1DBName.bak'
BUT HOW do I take this to the network. I tried
BACKUP DATABASE DBName
TO DISK = '\isl_fs1DBName.bak'
it doesn't work please help
View 2 Replies
View Related
Apr 8, 1999
Does anyone know if it is possible to use a variable in place of a database..table combination in a select statement
For Example: Instead of using the following with each database hardcoded in the SP:
select @dataused = sum(b.reserved)
from DBSglep..sysindexes b
where b.indid in (0, 1, 255) and segment != 2
I would like to loop for every database listed in sysdatabases and do this:
select @dbname = @dataname+'..sysindexes'
select @dataused = sum(b.reserved
from @dbname b
where b.indid in (0, 1, 255) and segment != 2
I have got the loop working, but just can't get the name substitution working as MSSQL dosn't seem to allow a variable after the FROM statement (it only seems to work with a hardcoded specific database..table name).
Any assistance in resolving this problem would be greatly appreciated! :-)
Many thanks in advance...
Regards,
Wayne
View 2 Replies
View Related
Jun 21, 2001
Last 2 nights (at night) my SQL Server has locked up, first night trying to back up MSDB(20 meg) and last night ran out of memory at 6:30 AM. No users on at either time, no jobs running on the second night. I was going to turn perfmon on tonite. Any input on what best to monitor?
View 2 Replies
View Related
Nov 28, 2007
Hello,I run out of space on the disk, my db log is 130GB, I need to shrink db log. I made a backup through network by UNC of the database, but when I want to backup log, I get a message :BACKUP LOG cannot be performed because there is no current database backup.But the backup is reachable, I can restore from it.Any ideas ?
View 8 Replies
View Related
Feb 14, 2013
I have a very simple query that gets a field to use as constraints in another query.
Code:
SELECT A.RIN
FROM apcType T
INNER JOIN apcAttribute a on A.T = T.RIN
WHERE T.Name like '%Sales'
The results of the first query are used in the following query where it is bolded and marked with and <<<<========
Code:
SELECT AP.Arg2, AP.Arg3, M.Parcel,
M.Serial, M.Name, M.Acres, M.District,
V.YearBuilt, V.Code, V.Size,
(SELECT SUM(V1.Acres)
FROM TRValue V1
WHERE V1.Year = V.Year and V1.Parcel = V.Parcel and
SUBSTRING(V1.Code, 1, 1) = 'L'
[code]....
My question is How can I fold the first query into the second?
View 1 Replies
View Related
Jan 7, 2004
thanks for reading.
i'm wondering if i can use a stored procedure in place of a UDF in the case where i want a return value based on a simple calculation involving the input parameter.
i'd like to use this inline in a query somewhere else. that's why the UDF.
the UDF would be something like this ...
create function getFiscalYear (@when datetime)
returns int
as
BEGIN
declare @rv int
-- months of Oct, Nov, Dec are rolled into following year
if datepart(month, @when) >= 10
select @rv = datepart(year, @when) + 1
-- whereas all other months stay in this year
else
select @rv = datepart(year, @when)
end
END
so, the only reason i'm not using this UDF (and haven't tested it either) is because i can't find (or can't remember how :( ) to add a UDF to my database. when i run this code in Query Analyzer i get an error on the keyword "function". but that's another question altogether.
thanks in advance. (a) for helping with a stored procedure that does the equivalent or (b) nudging me in the right direction towards getting UDFs to work in my SQL 2000 install.
View 5 Replies
View Related
Mar 11, 2004
Hi All!
I know that if is want to backup my db on the c: drive i do this
BACKUP DATABASE DBName
TO DISK = 'c:isl_fs1DBName.bak'
BUT HOW do I take this to the network. I tried
BACKUP DATABASE DBName
TO DISK = '\isl_fs1DBName.bak'
it doesn't work please help
View 2 Replies
View Related
Oct 15, 2013
I have a table called Register that has the following in it
Policy_number, Policy_date_time, Portfolio_set, Status..The rule for the table is that the last record for each portfolio_set for a policy the status needs to be 'A' but there have been instances that the last record status is 'I'
I need to identify the record that is out of place..In the example below record number 2.
example
policy_number Policy_date_time Portfolio_set, status
12345 1/1/2011 1 I
12345 1/2/2011 1 A
12345 1/3/2011 1 I
12345 1/4/2011 1 I
I need to identify that the second record is in the wrong place...
View 4 Replies
View Related
Oct 5, 2007
I have a stored procedure that starts like this:
.
.
.
UPDATE Employees
set depth=0, hierarchy=NULL
UPDATE Employees
set depth=1, hierarchy=right(@MaxPadLength + CAST(Employees.Parent AS varchar(255)),@DisplayPadLength)
where Child = Parent
WHILE EXISTS
(
SELECT *
FROM Employees
WHERE Depth=0
)
.
.
.
I have many tables that have the same structure as the Employees table but have different names. I would like to pass the PS a paramater with the table name I want to process. My question is what is the correct syntax to use a parameter in place of the literals for the table name?
Thanks
View 4 Replies
View Related
May 27, 2006
i have a table name is HH tableit has two columns 'hhno' and hhname'HH tabelehhno hhname100 suresh101 baba103 rami want to insert a one record(102 , chandra) in HH table between(101,baba) and( 103 ,ram).how can i insert them please help ,me thanks
View 10 Replies
View Related
Sep 28, 2007
How am I configuring permission for an SQL database, that user within my program should'nt read private information?
as well how can I protect my database with a UN & PWD to allow access only for authenticated users, not within the program, just the *.mdf file?
View 7 Replies
View Related
May 10, 2007
Hi,
While we choose in-place upgrade for upgrading to SQL Server 2005 from SQL Server 2000, does it actually change the code in Stored Procedures/functions also?
e.g. if I have *= in some old procedure does it change it to INNER JOIN while migrating?
Please help me on this ASAP.
Regards,
Rahul
View 1 Replies
View Related