Click here to Skip to main content
15,912,021 members
Home / Discussions / Database
   

Database

 
AnswerRe: Append the records to existing sp table Pin
Wendelius10-Nov-08 7:14
mentorWendelius10-Nov-08 7:14 
Question.Net OdbcConnection for Oracle Lite 40 ODBC Driver Pin
TheIdleProgrammer10-Nov-08 0:17
TheIdleProgrammer10-Nov-08 0:17 
AnswerRe: .Net OdbcConnection for Oracle Lite 40 ODBC Driver Pin
Wendelius10-Nov-08 5:25
mentorWendelius10-Nov-08 5:25 
GeneralRe: .Net OdbcConnection for Oracle Lite 40 ODBC Driver Pin
TheIdleProgrammer10-Nov-08 21:14
TheIdleProgrammer10-Nov-08 21:14 
GeneralRe: .Net OdbcConnection for Oracle Lite 40 ODBC Driver Pin
Wendelius11-Nov-08 8:15
mentorWendelius11-Nov-08 8:15 
GeneralRe: .Net OdbcConnection for Oracle Lite 40 ODBC Driver Pin
TheIdleProgrammer11-Nov-08 21:25
TheIdleProgrammer11-Nov-08 21:25 
GeneralRe: .Net OdbcConnection for Oracle Lite 40 ODBC Driver Pin
Wendelius13-Nov-08 10:36
mentorWendelius13-Nov-08 10:36 
QuestionSQL Trigger to get updated cell Pin
Indra PR10-Nov-08 0:05
Indra PR10-Nov-08 0:05 
I just got some SQL Query to get updated cell like below:
CREATE TRIGGER LaurenQuantrell
ON Lauren AFTER UPDATE
AS
IF UPDATE(KeyCol)
BEGIN
RAISERROR ('Dont change the key column!!', 16, 1)
ROLLBACK TRANSACTION
RETURN
END

INSERT Quantrell (KeyCol, ColName, NewData)
SELECT inserted.KeyCol, 'DataCol1', inserted.DataCol1
FROM inserted
INNER JOIN deleted ON deleted.KeyCol = inserted.KeyCol
WHERE inserted.DataCol1 <> deleted.DataCol1

INSERT Quantrell (KeyCol, ColName, NewData)
SELECT inserted.KeyCol, 'DataCol2', inserted.DataCol1
FROM inserted
INNER JOIN deleted ON deleted.KeyCol = inserted.KeyCol
WHERE inserted.DataCol2 <> deleted.DataCol2

INSERT Quantrell (KeyCol, ColName, NewData)
SELECT inserted.KeyCol, 'DataCol3', inserted.DataCol3
FROM inserted
INNER JOIN deleted ON deleted.KeyCol = inserted.KeyCol
WHERE inserted.DataCol3 <> deleted.DataCol3

And, I want to change it into dynamic SQL since it is too much to type the column one by one:
DECLARE @COLUMN_NUMBER AS integer
DECLARE @COLUMN_TOTAL AS integer
DECLARE @COLUMN_NAME AS nvarchar(100)
DECLARE @SQL AS nvarchar(1024)

SET @COLUMN_NUMBER = 1
SET @COLUMN_TOTAL = (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'transaksi_request')

WHILE @COLUMN_NUMBER <= @COLUMN_TOTAL
BEGIN
SET @COLUMN_NAME = (SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'transaksi_request' AND ORDINAL_POSITION = @COLUMN_NUMBER)
SET @SQL =
'INSERT transaksi_requestlog(log_date, log_user, log_id, log_column)
SELECT ''' + CAST(GETDATE() AS nvarchar(20)) + ''', Inserted.request_modifiedby, Inserted.request_id, ''' + @COLUMN_NAME + '''
FROM Inserted
INNER JOIN Deleted ON Deleted.request_id' + ' = Inserted.request_id' + '
WHERE Inserted.' + @COLUMN_NAME + ' <> Deleted.' + @COLUMN_NAME
EXEC(@SQL)

SET @COLUMN_NUMBER = @COLUMN_NUMBER + 1
END

And it got an error message saying Invalid object name 'Inserted'

Can anyone help me?

Thanks

- No Signature Available -

AnswerRe: SQL Trigger to get updated cell Pin
Wendelius10-Nov-08 4:44
mentorWendelius10-Nov-08 4:44 
QuestionA transport-level error has occurred when sending the request to the server. Pin
Nitin J. Jain9-Nov-08 23:30
professionalNitin J. Jain9-Nov-08 23:30 
AnswerRe: A transport-level error has occurred when sending the request to the server. Pin
Ennis Ray Lynch, Jr.10-Nov-08 3:33
Ennis Ray Lynch, Jr.10-Nov-08 3:33 
QuestionSql Statment ProbLem Pin
soniasan9-Nov-08 23:25
soniasan9-Nov-08 23:25 
AnswerRe: Sql Statment ProbLem Pin
Wendelius10-Nov-08 4:32
mentorWendelius10-Nov-08 4:32 
QuestionDatetime datatype conversion failed in sqlserver 2008 Pin
param_joshi9-Nov-08 21:48
param_joshi9-Nov-08 21:48 
AnswerRe: Datetime datatype conversion failed in sqlserver 2008 Pin
param_joshi9-Nov-08 23:51
param_joshi9-Nov-08 23:51 
GeneralRe: Datetime datatype conversion failed in sqlserver 2008 Pin
Wendelius10-Nov-08 5:43
mentorWendelius10-Nov-08 5:43 
Question[Message Deleted] Pin
B879-Nov-08 19:58
B879-Nov-08 19:58 
AnswerRe: Adding Pin
Ashfield9-Nov-08 20:20
Ashfield9-Nov-08 20:20 
QuestionHow do I create Database Script? Pin
graced889-Nov-08 15:14
graced889-Nov-08 15:14 
AnswerRe: How do I create Database Script? Pin
Wendelius10-Nov-08 4:49
mentorWendelius10-Nov-08 4:49 
GeneralRe: How do I create Database Script? Pin
graced8810-Nov-08 5:09
graced8810-Nov-08 5:09 
GeneralRe: How do I create Database Script? Pin
graced8810-Nov-08 5:12
graced8810-Nov-08 5:12 
GeneralRe: How do I create Database Script? Pin
Wendelius10-Nov-08 5:27
mentorWendelius10-Nov-08 5:27 
Questionabout combo box Pin
cutedrew9-Nov-08 15:00
cutedrew9-Nov-08 15:00 
AnswerRe: about combo box Pin
Ashfield9-Nov-08 20:22
Ashfield9-Nov-08 20:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.