MS SQL Query all table too slow

I’m encoutering a problem with my query. i’m in MS SQL and I try to get all associated table from my patient. From here,everything is going fine. I build up my query first then I execute it. When I execute it, It takes more than 2 min to finish. It’s way too long And I […]

What does two return statements inside an SQL function mean?

I am new to SQL. I am analyzing this SQL Function that calculates Safety stock and I ran into something that I have never seen before. This is a Scalar function that returns a decimal. However the end of the code goes like this: DECLARE @SafetyStockUnitsCalcNew decimal(14,2) RETURN( SELECT STDEV( . . Code for calculating […]

Database design: a many-to-one design where order matters

I have two tables, User and Game. Game has columns sideRed and sideBlue. Each side has exactly one user. User has column activeGame. If sideRed and sideBlue are one-to-one relationships, then where does the back reference activeGame go?

Update with Join

SourceTable ———– Global_id int Product_id varchar Category int Status int Client —— Client_id Global_id … References ———- Client_id Category int Status int … I am trying to update values of Category and Status columns in References table. The source data with which to update comes from the following query (returns more than one row). select […]

Dynamic attributes for a model

I’m currently creating a document management system where the user should be able to configure the supported document types and therefor the documents attributes. My current conceptional ERD for the template looks like this: but if i would like store my documents in this way, i it would create for each document with 2 attributes […]

Retrieve corresponding foreign key with drop-down list (WCF) C#

I’m using WCF services to load my database table to the drop-down list (combobox). How do I retrieve the selected value into a corresponding value in the table, so when I select an item, the corresponding int will be inserted to the table? Here is my code for the desktop layer: private void Save() { […]

ColumnStore Index – Maximum Rows in a RowGroup – 1,048,576 OR 102,400?

I was trying to understand, the architecture of Columnstore Indexes – SQL Server 2016. Ref: https://msdn.microsoft.com/en-us/library/gg492088.aspx#Anchor_4 Here, the minimum rows in a rowgroup to move in to the column store is mentioned as 102400, But it is also mentioned, that 1,048,576 rows are usually stored in a rowgroup. So how is this balance maintained? -Yasub

Split String Value in SQL for Flexible Filtering

I have a function where in user can assign multiple categories (food, non food etc) to a certain Tenant. See sample Data Table Table: tblSales date tenant sales category 1/1/2015 tenant1 1000 Food,Non-Food,Kiosk 1/1/2015 tenant2 2000 Food 1/1/2015 tenant3 1000 Non-Food,Kiosk The system should be able to load record when the user selected any of […]

Add multiple SQL values with same parameterized query?

I’m fairly new to SQL and trying to figure out the best way to add some predefined data. I figured out from searching around here that I should used a parameterized command to avoid a sql injection attack which isn’t a huge concern in this case but I would like to avoid the possibility and […]

Is it Possible to get the multiple set result into single set of result in SQL Server?

My SQL table looks like this CREATE TABLE [CONTENTS].[ID] ( [ID] NVARCHAR (20) NOT NULL, [NAME] NVARCHAR (MAX) NOT NULL, [CONTENT] NVARCHAR (MAX) NULL, [PARENT_ID] NVARCHAR (20) NOT NULL, [TYPE] INT NOT NULL, [SHARED] INT NOT NULL, [CREATED] DATETIME NULL, [ICON] VARBINARY (MAX) NULL, [UPDATED] DATETIME NULL ); Every item has the parent item except […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.