I’m trying to SET more than one value within the if else statement below, If I set one value it works, but if I set two values, it doesn’t work: Error message: “Msg 156, Level 15, State 1, Line 9 Incorrect syntax near the keyword ‘ELSE’.” However it seems to be possible to have multiple SET variables after the else;
Tag: tsql
WITH(NOLOCK) : where & when to use
I have 15 tables which are normalized to contain records and many user may be inserting/updating data in these tables( No two user can update the same record(s) simultaneously, this is restricted by client implementation). these 15 tables are updated 1 by 1 in a stored procedure. WITH(NOLOCK) is used where select statements are to avoid read locks as some
Rounding dates to first day of the month
I am using SQL Server 2014 and I am working with a column from one of my tables, which list arrival dates. It is in the following format: ArrivalDate 2015-10-17 00:00:00.000 2015-12-03 00:00:00.000 …
Group rows of data from table based on a column
I want to achieve the below using SQL can anyone please help: TOP BOTTOM Rocksymbol 0 5 l 5 10 l 10 15 ml 15 20 ml 20 25 …
drop trigger if exists and create
I would like to check if the trigger exists on [tbl] and create another one. I tried it this way but didn’t work. What am I doing wrong? Answer The [name] field in sys.objects will contain only the actual name (i.e. trg), not including the schema (i.e. dbo in this case) or any text qualifiers (i.e. [ and ] in
Can’t see created tables in Object Explorer – Microsoft SQL Management Studio
I am trying to create some tables within a database, however the tables are not appearing in my object explorer view. my code is as follows: I looked this up before posting and found this exact question: Creating table with T-SQL – can’t see created tables in Object explorer However, he was using “tempdb”, which I am not. I ran
T-SQL Dollar Sign In Expressions
In this answer, there is a trick which allows to use the ROW_NUMBER() windowed function with a ‘constant’ in the ORDER BY clause: After some search in Google, I can’t find what dollar sign means in this context? I’ve tried to execute a simple query: And it returns 0. Could somebody explain this? Answer It’s just a money constant (what
java.sql.SQLException: Field ‘id’ doesn’t have a default value
I am trying to insert data into arrivaltimes tables but I am getting the following error: java.sql.SQLException: Field ‘id’ doesn’t have a default value Answer You are missing AUTO INCREMENT for Primary Key in arrivaltimes table. Just need to add AUTO_INCREMENT while creating table
Bulk insert in SQL Server database from one table to another
I have 200k records in one table and I want to insert these records into another table. I read about the bulk insert but the query I found on msdn website is just not making any sense. This is the query What is f:orderslineitem.tbl and the whole this is just not making any sense. I have a table with four
Do I need a where clause in a conditional UPDATE?
We imported a lot of data from another table. Now I’m trying to correct some of them. I didn’t use ELSE because many rows have valid country. My question is to know whether I need to the WHERE clause to filter the rows that will be affected? The reason I’m asking this question is that, I’ve selected into a test