I’m new to data warehouse, So I try to follow the best practice, mimicking some implementation details from the Microsoft Demo DB WideWorldImportersDW, One of the things that I have noticed is using Sequence as default value for PK over Identity. Could I ask, If it’s preferable to use Sequence ove…
Tag: sql-server
Retrieving row and column number from within a string in sql
I am trying retrieve row and column number for following strings. The numbers that follow the R are the row no and numbers that follow the C are column numbers. Also as you can see some of them are 4 digits and some of them are 3 digits. How do I use a single function to retrieve the row and
Remove the middle row of the SQL table
In My SQL Table store the Status record. There are 4 main status Open, New, Completed, and closed. There can be many New Status. But Open, Completed, and Close should only one status. But we can close status Reopen(ID 102) For the particular sequence SEQ column is the unique ID. we can consider ID and SEQ as …
Updating specific rows to values based on the count of rows in another table
I have a table RESERVED_BOOKINGS_OVERRIDDEN and another table ALLOCATED_PRODUCTS Now I need to update the ReservedQuant column in the ALLOCATED_PRODUCTS table based on the rows in RESERVED_BOOKINGS_OVERRIDDEN The ReservedQuant must minus by the amount of rows found where the ALLOCATED_PRODUCTS.Date is within …
select distinct and autoincrement field in select query
I have a table Product with So i need a select query that will display distinct product no with ids for displaying in p-listbox. say How do i achieve this? Thanks Answer One method is: That said, I would probably use group by:
Microsoft SQL Server , view transformation
Is it possible to transform the following view : to this structure ? I’ve tried with cross join but I have no idea how to make a condition based on column name. Answer You need APPLY instead of JOIN to be able to access outer columns
SQL query to unpivot and union for multiple column
I’m trying to achieve the following result… input, table A I would obtain this output I’m trying to use cross apply and I can create the column “month_year” but I don’t know how to merge “values” in the last column. Thanks for help! Answer I think this is basica…
SQL SERVER: OPTION(MAXRECURSION n) not working with dynamic variables
Techies, This more or less works when the date range is between 1/1/-1/3. I have 2 problems I need to solve. The first is that SQL Server will not let me do this: OPTION (MAXRECURSION @recdays). The next, I am pulling results for 1/4, when I only want results up to 1/3. Any advice for getting this to work? I
split data in a single row into multiple records
I need to split a comma separated field into multiple records based on ‘,’ Answer Youll want to use string_split like this:
SQL Compare rows of a table with multiple columns
I have a table T1 Id Col1 Col2 IsActive 1 T1 v1 1 2 T2 v2 0 Now received the following data and it need to be inserted into the above table. As this data contains some duplicated values, it need to be inserted based on IsActive Column value. For row with IsActive 1, need to insert with IsActive 2