I have a question regarding the following syntax. Is there a cleaner way to roll this up into one statement rather than two. I’ve tried several iterations but this seems to be the only way I can successfully execute these two statements.
UPDATE employee SET hire_date = '1979-03-15' WHERE emp_id = 'PMA42628M' UPDATE employee SET hire_date = '1988-12-22' where emp_id = 'PSA89086M';
I tried this as well and I also tried using an AND statement. Neither worked. Basically I am looking for a less newbie way then the method above, if one exists. I spent a long time searching and did not find one.
UPDATE employee SET hire_date = ('1979-03-15', '1988-12-22') WHERE emp_id = ('PMA42628M', 'PSA89086M');
Appriciate any advice on this one, and by the way, I am using sql server. Thanks
Related Posts:
- How can I do an UPDATE statement with JOIN in SQL Server?
- I want to use CASE statement to update some records in sql server 2005
- I want to use CASE statement to update some records in sql server 2005
- Update query using Subquery in Sql Server
- LIKE vs CONTAINS on SQL Server
- What is an MDF file? [closed]
- Selecting COUNT(*) with DISTINCT
- Case in Select Statement
- What is the difference between varchar and nvarchar?
- Conversion failed when converting date and/or time from character string while inserting datetime
- Self Join to get employee manager name
- How do I UPDATE from a SELECT in SQL Server?
- SQL query to select dates between two dates
- When should I use CROSS APPLY over INNER JOIN?
- Insert Data Into Temp Table with Query
- How to create Temp table with SELECT * INTO tempTable FROM CTE Query
- NOT IN vs NOT EXISTS
- Must declare the scalar variable
- Must declare the scalar variable
- INSERT statement conflicted with the FOREIGN KEY constraint – SQL Server
- Efficiently convert rows to columns in sql server
- Update multiple columns in SQL
- Nested select statement in SQL Server
- INSERT statement conflicted with the FOREIGN KEY constraint – SQL Server
- How do I escape a single quote in SQL Server?
- T-SQL split string based on delimiter
- How to rename a table in SQL Server?
- Drop a temporary table if it exists
- How do I escape a single quote in SQL Server?
- IDENTITY_INSERT is set to OFF – How to turn it ON?
- SQL update from one Table to another based on a ID match
- Column name or number of supplied values does not match table definition
- Inserting data into a temporary table
- Can a foreign key be NULL and/or duplicate?
- Why does NULL = NULL evaluate to false in SQL server
- CREATE VIEW must be the only statement in the batch
- SQL Server FOR EACH Loop
- Difference between JOIN and INNER JOIN
- “CASE” statement within “WHERE” clause in SQL Server 2008
- What is the difference between Scope_Identity(), Identity(), @@Identity, and Ident_Current()?
- Each GROUP BY expression must contain at least one column that is not an outer reference
- How can I truncate a datetime in SQL Server?
- DateTime2 vs DateTime in SQL Server
- Difference between numeric, float and decimal in SQL Server
- SQL Server Insert if not exists
- SQL Server: Invalid Column Name
- SQL Server reports ‘Invalid column name’, but the column is present and the query works through management studio
- How to parse XML data in SQL server table
- What is the equivalent of ‘describe table’ in SQL Server?
- SQL Server IF NOT EXISTS Usage?
- How do I query for all dates greater than a certain date in SQL Server?
- String or binary data would be truncated. The statement has been terminated
- Add a column with a default value to an existing table in SQL Server
- Error converting data type varchar to float
- Remote table-Valued Function Calls are not allowed
- How to concatenate text from multiple rows into a single text string in SQL Server
- Count(*) vs Count(1) – SQL Server
- What is the Oracle equivalent of SQL Server’s IsNull() function?
- The backend version is not supported to design database diagrams or tables
- Determine ROW that caused “unexpected end of file” error in BULK INSERT?
- Determine ROW that caused “unexpected end of file” error in BULK INSERT?
- Conversion failed when converting the varchar value ‘simple, ‘ to data type int
- Must declare the scalar variable
- Exclude a column using SELECT * [except columnA] FROM tableA?
- Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 4 (Year)
- Why is SQL server throwing this error: Cannot insert the value NULL into column ‘id’?
- Bulk load data conversion error (truncation)
- SQL “select where not in subquery” returns no results
- ListAGG in SQLSERVER
- Regex pattern inside SQL Replace function?
- mysql update column with value from another table
- ‘CREATE PROCEDURE’ must be the only statement in the batch (Erro)
- Errors: “INSERT EXEC statement cannot be nested.” and “Cannot use the ROLLBACK statement within an INSERT-EXEC statement.” How to solve this?
- Replacing NULL with 0 in a SQL server query
- SQL Server dynamic PIVOT query?
- Incorrect syntax near ”
- How to write a foreach in SQL Server?
- Error converting data type varchar
- SQL Server “cannot perform an aggregate function on an expression containing an aggregate or a subquery”, but Sybase can
- Get everything after and before certain character in SQL Server
- Cannot create an instance of OLE DB provider Microsoft.Jet.OLEDB.4.0 for linked server null
- How to calculate age (in years) based on Date of Birth and getDate()
- ORDER BY items must appear in the select list if SELECT DISTINCT is specified
- The server principal is not able to access the database under the current security context in SQL Server MS 2012
- Solutions for INSERT OR UPDATE on SQL Server
- Text was truncated or one or more characters had no match in the target code page including the primary key in an unpivot
- How can I group by date time column without taking time into consideration
- What are database constraints?
- Inner Joining three tables
- Append table to an existing one: SQL Server
- SQL Server – An expression of non-boolean type specified in a context where a condition is expected, near ‘RETURN’
- ORA-01779: cannot modify a column which maps to a non key-preserved table
- “select * into table” Will it work for inserting data into existing table
- INSERT VALUES WHERE NOT EXISTS
- SUM OVER PARTITION BY
- CASE IN statement with multiple values
- How to implement LIMIT with SQL Server? [duplicate]
- Varchar invalid for Sum operator
- Cannot insert explicit value for identity column in table ‘table’ when IDENTITY_INSERT is set to OFF
- How to dump a Microsoft SQL Server database to a SQL script?