Disallow A Specific Column's Value From Getting Updated

Jul 9, 2007

is there a way to do this in create/alter table without the overhead of a trigger? I want to ensure that one of the 'key' values (even though it may be duplicated) cannot change after it's been inserted.

View 4 Replies


ADVERTISEMENT

Bit More Specific, Can One Pass An NVARCHAR To IF UPDATED()?

Jun 21, 2004

Question is pretty much in the thread title.

I'm still plunking away on a history trigger that requires the evaluation of whether or not each column has been updated. If it has,t hen I'll be tossing a record into a history table.

Basically I need something to function along the same logic as this:

IF UPDATED(@s)
BEGIN
--some code
END

Any thoughts you folks may have are greatly appreciated.

View 2 Replies View Related

Transact SQL :: Select Specific Values From All Rows Where Value Of A Specific Column Is (Active)

May 23, 2015

I need to select specific values from all rows where the value of a specific column is "Active"

This part works: SELECT LastName, FirstName, MiddleInit, ClientId FROM dbo.Client

But I want to add: WHERE StatusType = (Active) and how to do this.

View 4 Replies View Related

Disallow Duplicates

Feb 1, 2007

SQL Server 2005 express - how do you disallow duplicates on a non-identity column? E.g. CompanyName

View 1 Replies View Related

Update Field With Trigger Only If A Specific Field Is Updated

Nov 11, 2013

I want to update a field with a trigger only if a specific field is updated.

When I try the code below, it updates the field when any field in the record is updated. Is there a way to only make look at picked_dt?

ALTER TRIGGER [dbo].[UpdatePickedDate]
on [dbo].[oeordlin_sql]
after update
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from

[Code] .....

View 4 Replies View Related

Updated Column Name

Feb 10, 2005

Hi,

Can anybody tell me how to find the column name(s) for recently updated table.

Thanks,

Kishore

View 6 Replies View Related

Updating Modified/updated Date Column?

May 13, 2008

If your tables contain created and modified/updated dates what is the best practice for these?

1. Should you use UTC dates?
2. Do you use a default for the creation date (I assume yes)?
3. Should you create a trigger to handle the last update date? Or do you update the column directly in your stored procedures that modify data?

Also, as an aside if you store the user who created/updated the record do you store a foreign key reference to the user table or do you store the username as a varchar? Of course I know you'd normally store the fk, but I wasn't sure if the "logging" nature of the column suggests storing a string value.

View 2 Replies View Related

Record Not Updated Or Deleted When Any Column Consists The Null Value

Oct 23, 2007

Hi All  In My application when i want to work with sqldatasource for updation and delteion tasks it is working properly when all the columns consists the data. If any of the column consists the null values its not updating and deleting. Advices are needed.Thank uBaba 

View 4 Replies View Related

Trigger Not Running When Trying To Select Data From A Column That Is Being Updated?

Dec 11, 2006

Trigger not running when trying to select data from a column that is being updated?

View 1 Replies View Related

SQL Server 2012 :: Updated Aggregate Column Where Value Is A Rolling Sum

Apr 29, 2014

I am trying to create an aggregate table where the value is a rolling sum. Type a on date 1 is the sum of the values in the main tbl. Type a on date 2 is the sum of values for type a on date 1 and date 2. Is this possible? I have been trying update t sql with sum(case where date <= date) statements but can't get it to run.

create table main_table (type nvarchar(10), date int, datavalues int);
insert into main_table
values('a', '1',3);
insert into main_table
values('b', '1',4)

[Code] .....

View 9 Replies View Related

Transact SQL :: How To Get Info Which Stored Procedure Updated A Column For Particular Timestamp

Jul 31, 2015

How to get the details of a stored proc or sql query which updated a particular table for specified time stamp or interval. Is there any query to get this?

View 3 Replies View Related

Add One To Each Row In A Specific Column

Sep 22, 2007

I need to increment a value in some rows to keep a list in order. Here's the idea:

UPDATE myList SET OrderNum = OrderNum + 1 WHERE UserID = @UserID, OrderNum >= @OrderNum

This throws an exception. Is there a quick and easy way to update like this?

View 5 Replies View Related

Data To Their Specific Column

Oct 11, 2005

hi there

i'm using this code

DECLARE @strComma VARCHAR(1000)
SET @strComma = 'cmpnt_name,ASC,1,2'
SELECT CAST(RIGHT(LEFT(@strComma,Number-1), CHARINDEX(',',REVERSE(LEFT(','+@strComma,Number-1)))) AS CHAR(30))
FROM master..spt_values
WHERE Type = 'P' AND Number BETWEEN 1 AND LEN(@strComma)+1 AND (SUBSTRING(@strComma,Number,1) = ','
OR SUBSTRING(@strComma,Number,1) = '')

however i getting the data in one field which is like

cmpnt_name
ASC
1
2

i would like them to be in their specific column that is 4 different field

Name-----------Char----------Length---------Order
cmpnt_name-----1--------------2-------------ASC

thx u

View 4 Replies View Related

Query To Get Column Name With Specific Value

Jul 20, 2005

Here is tested schemaif exists (select * from dbo.sysobjects where id =object_id(N'[dbo].[TestTable]') and OBJECTPROPERTY(id, N'IsUserTable')= 1)drop table [dbo].[TestTable]GOCREATE TABLE [dbo].[TestTable] ([SerialNumber] [char] (12) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[test1] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,[test2] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,[test3] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,[test4] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL) ON [PRIMARY]GOinsert into testtable values ('123','pass',null,'fail','skip')insert into testtable values ('456','fail',null,'pass','skip')insert into testtable values ('789',null,'fail','skip','pass')insert into testtable values ('345','pass','pass','pass','fail')I would like to fetch the COLUMNNAME where the value is fail.Basically I need to know which test failed, test1, test2, test3 ortest4?Is this possible?

View 2 Replies View Related

Add Column In Specific Position

Dec 12, 2007

What is the SQL for adding a column at specific location?

eg
TableA
colA
colB

I want to add colC after colA.


Thanks,
Max

View 1 Replies View Related

Inserting New Column In Specific Place

Jan 15, 2007

Hi

In MySQL it's simple to insert new columns in specific locations in a table like this


sql Code:






Original
- sql Code





alter table foo add column bar integer not null default 0 after baz






 ALTER TABLE foo ADD COLUMN bar integer NOT NULL DEFAULT 0 AFTER baz



But attempting to do the same thing in MSSQL fails with a syntax error on the word "after." I can insert columns in MSSQL but only if they are added to the end. I looked at the Microsoft insert documentation here but don't see any way to replicate the above MySQL command.

Is there any way to do this in MSSQL? Or do I have to completely recreate all my tables from scratch?

Thanks for any help

View 6 Replies View Related

Checking All Tables That Have Specific Column Name?

Jan 5, 2012

Is there a command I can use to tell me all the tables in my schema that have a column name "Id"?

View 5 Replies View Related

Modify All Data Within A Specific Column

Aug 15, 2007

I have a column (PERIMAGE_PATH) in my table. The data in this column is imported from a fixed width text file and looks like the following:

07J06274
05J03254
04J11245

I need to modify the data in the column to look like this:

..images7J06274.jpg
..images5J03254.jpg
..images4J11245.jpg

How can I do this?

Thanks for all your guys' help. This is the last question for the day. I promise

View 8 Replies View Related

Return Max Value Of Specific Table Column

Aug 9, 2007

Hello Reporting specialists ... (GregSQL, Jarret, Lisa .....)

How can i get the max value of a single specific table column ??

Is this possible ? Or am i asking the impossible ??

Hopelessly, desperatelly remaining ...
Vinnie


see also http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1979307&SiteID=1

View 1 Replies View Related

Find Out What Tables Contain A Specific Column

Jul 28, 2006

I want to write SQL that will search the tables in a database for a specific column, like this. For instance, I have a column "Unique_ID" that is in many of our tables (hundreds) but not in others and want to find out the tables it is in. It is always the first column.

I tried to find a system stored procdure to do this but couldn't and tried to create a script using the sysobjects and syscolumns tables in the Master db, but came to a roadblock because they don't seem to be related at all.

I would surely appreciate if someone else has already done this!

Thanks!

View 6 Replies View Related

Select Specific Column In Front Of Star

Jul 8, 2014

In SQL Server I can select a specific column in from of * like so:

Code:
select test_column_1,* from testtable1

I've been googling around and cannot seem to be able to find a definitive answer.

View 1 Replies View Related

T-SQL (SS2K8) :: Concatenate Specific Values From A Column

May 20, 2014

Give this data set;

declare @BO table (Col1 varchar(50), Col2 varchar(50))
insert into @BO values
('01','009920140516102116'),
('071710811019600001000005',''),
('070534524264000001000005',''),
('001806505517000001000005',''),

[Code] ....

select * from @BO

The 2 digit number that appears on line 1, 7 and 13 (only in this example) i need to have added to the begin of each value below it until the next 2 digit number is encountered. The desired result set would look like:

declare @BOD table (Col1 varchar(50), Col2 varchar(50), col3 varchar(50))
insert into @BOD values
('01','009920140516102116',''),
('071710811019600001000005','','01071710811019600001000005'),
('070534524264000001000005','','01070534524264000001000005'),

[Code] ....

View 7 Replies View Related

SQL 2012 :: Remove Character From Specific Column

Nov 18, 2014

How to remove Character From Column,Just Character. I want to work with number.

View 4 Replies View Related

T-SQL (SS2K8) :: Specific Column Matching With Nulls

Apr 9, 2015

I'm working on a join between two tables where I only want one row returned... I'm matching on two columns between two tables. One of those columns in the target table could be null. I only want one record returned.

create table #vehicle(id int, vehiclemake varchar(10), vehiclemodel varchar(10), classtype varchar(1))
create table #class(id int, classtype varchar(1), value int)

insert into #vehicle values(1, 'AUDI', 'R8', 'A')
insert into #vehicle values(2, 'AUDI', null, 'B')

insert into #class values(1, 'A', 100)
insert into #class values(2, 'B', 1)

[Code] ....

Using the above example, if VehicleModel is anything other than 'R8' is specified then I want it to return the other class type record.

This is going to be used as a join within a bigger statement, so I'm not sure ordering and returning top 1 is going to work.

View 9 Replies View Related

Search For Specific Length String In Column

Sep 14, 2007

SQL 2000.I need a query that will search a field in the table that is 14characters long and begins with a number.I have a client that was allowing people to store credit card numbers,plain text, in an application. I need to rip through the table andreplace every instance of credit card numbers with "x" and the last 4digits. I got the replace bit going, but I am stuck on how to searchfor a string in a field of a specific length.Any ideas?Thanks,--Mike

View 5 Replies View Related

Matrix - Hiding A Specific Row In Column Total

Feb 1, 2007

Hi,

I have created a matrix with multiple rows in the main data cell and a subtotal at the end of the row. The first row in my matrix main cell is just a count of records, whereas the 2nd row is a % of the value in the 1st row compared to the total of that row. I have 5 columns in the matrix as below (only first row is shown plus the total row. Ignore any rounding issues):










Status
A
B
C
D
E
Total

02/01/2007
No.
9
32
3
13
0
57

% Total
15.00%
56.00%
5.00%
24.00%
0.00%
100.00%

Total
No.
77
143
25
72
2
319

% Total
135.00%
350.00%
48.00%
250.00%
2.00%
556.00%

I have a total column at the end. I want to hide the %Total row within the total row as it does not make sense in this context. Anyone know how to achieve this?

Thanks

View 4 Replies View Related

How Can Update Specific Column In Existing Table

Feb 4, 2006

I am building a data warehouse. I have many columns I want to populate in a fact table using integration services. Sample fields are: companyID, companyName, companyNumberOfAccounts, company, NumberOfUsers.

In the integration services package, I would like to keep this fact table in place and populated with data and to build integration services packages that update each of the existing row's specific columns (e.g. companyNameOfAccounts) one by one. For example, I have a source of data that has companyID and companyNumberOfAccounts data.

Is it possible to use the SQL Server Destination or OLE DB Destination Integration Services elements to import companyID and companyNumberOfAccounts data so that existing records just have their companyNumberOfAccounts column updated?

View 1 Replies View Related

Save Updated Date When Row Is Updated

Apr 6, 2008

Hi,I want to save the last modification date when the row is updated. I have a column called "LastModification" in the table, every time the row is update I want to set the value of this column to the current date. So far all I know is that I need to use a trigger and the GetDate() function, but could any body help me with how to set the value of the column to getdate()? thanks for your help. 

View 3 Replies View Related

Updating Specific Columns If That Column Is Equal To A Value In One Query?

Dec 8, 2006

I want to set a column to 0 if it is set to a certain number. There are several columns to check though, so I am wondering if I can do it all in one query, or if I have to do it in single queries?

here is an example:

account | contact_id_1 | contact_id_2 | contact_id_3
433 | 67 | 23 | 67

so I want to set any contact_id_N = 0 where contact_id_N is = 67

so in the end, the table will look like this:

account | contact_id_1 | contact_id_2 | contact_id_3
433 | 0 | 23 | 0

is there a way to do it in one statement?

View 2 Replies View Related

T-SQL (SS2K8) :: Find All Rows From All Tables In A DB For Specific Column?

Mar 28, 2014

I have a DB with some tables and, on certain tables, i've a column named "ID_COMPUTER".

I need to find all the rows where id_computer=<specific_value> from all the tables of my database, when column "ID_COMPUTER" exists.

Pseudo-code would be: select * from db.* where id_computer=<specific_value>

how to write this ?

View 2 Replies View Related

SQL 2012 :: Selecting From Linked DB2 Server / Specific Column

May 13, 2014

I've got an OLEDB DB2 linked server to a db2/AS400 instance and selecting from a table on the server has never caused problems before. One of the columns is a large text field. If I select all the columns but the large text field, it returns as normal, but including the large text field now, I get:

"Transport error: shared memory provider error: 0 - no process is on the other end of the pipe"

The largest entry in the text field is about 5k characters, and there don't appear to be any strange characters.

View 0 Replies View Related

T-SQL (SS2K8) :: How To Make A Column Comply To A Specific Format

Dec 4, 2014

I need to insert and update a table. One column of the table needs to conform to a format as: XXXXXXX.XXXXX

If any data is not complying to the format an error needs to be thrown.

How to implement this constraint!

View 3 Replies View Related

SQL Server 2014 :: Check If Two Rows Have A Different Value In A Specific Column

Sep 9, 2015

I have huge export files in a DB and i need to check if there are any datasets that have the same value in the first column, but a different in another one, via a query of course.

Like this:

ID IS NULL
1 1
2 1
3 0
1 0

The expected ID i get as a result of my query should be 1 in this case.

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved