Questions tagged [sql-server]

Microsoft SQL Server is a relational database management system (RDBMS). Use this tag for all Microsoft SQL Server editions including Compact, Express, Azure, Fast-track, APS (formerly PDW) and Azure SQL DW. Do not use this tag for other types of DBMS (MySQL, PostgreSQL, Oracle, etc.). Do not use this tag for issues on software and mobile development, unless it is directly related to the database.

320,022 questions
0votes
0answers
4views

How would I ensure data congruity for a JSON column in SQL Server?

We decided to store some 'meta data' per record for one of our entities (Let's call this entity Order). Let's say that this Order contains other entities named 'Item'. One piece of meta data we store ...
0votes
0answers
13views

How to compare two dates in SQL

Given two dates in the format Date1 = 3/8/2021 12:00:00 AM Date2 = 7/19/2021 12:00:00 AM I need to determine if Date1 is father in the past compared to Date2 With these dates Date1 is further in the ...
0votes
0answers
18views

Does using a function calling GETDATE() in a view consistently give dramatically worse performance than using GETDATE() directly?

I have a function that gets the Monday of the week @X weeks in the past/future. I bolted it together from other code on this website. I believe it goes like this: CREATE FUNCTION [FOO] ( @X INT ) ...
  • 1,634
-1votes
0answers
7views

Account Ledger display query

There are 2 tables Ledger and transaction Ledger Table has below fields LID,LName,Lgroup,Opbal Transaction Table has Txno,Tandate,LID,TXnType,Amount,Narration Below Are The data Ledger Table LID, ...
0votes
0answers
18views

Is there a way to write this python function for MSSQL using pure SQL in a stored procedure, without SQL Alchamey

I have a dataframe of sales data containing product_id, store_id, year, week, quantity_sold. I am able to normalize the quantity_sold and group by the columns as specified below and this gives me the ...
0votes
0answers
20views

How to share a single sequence between multiple SQL Server databases?

I need to share a single SQL Server sequence between tables in two different SQL Server databases. This example works just fine for two existing tables and a sequence defined on the same database: ...
0votes
0answers
18views

Querydsl - cross apply json

I want to use cross apply from sql-server in my querydsl-sql query with a json field but cant get it right. I have two tables: old_table and updated_table which I want to merge. The data to merge: ...
2votes
3answers
39views

How to keep NULL values in STRING_SPLIT

Please excuse formatting, this is my first post. I have a table like the one below: id code Fig 1 AAA [email protected]@2-2-3 2 AAB [email protected]@2-2A-2-4 3 AABA NULL 4 AAC [email protected] My code is ...
0votes
2answers
19views

SQL Query for one to many bridge table

I am trying to find a logic to return the unique group from TableGroup where country of all members from bridge table TableMember is equal to US. if any of the member is from other country then it ...
0votes
0answers
25views

Finding 90th percentile when data is in aggregated format in SQL

I have data in following format: Score Count of student 100 12 99 32 98 13 97 12 96 33 95 42 94 13 93 14 Basically score and a count of student scoring that much score. How do I find 90th ...
  • 2,403
0votes
1answer
19views

How to convert to UTF-8 in SQL Server database?

i'm working on mssql server 2017. i got table with 'name' nvarchar column with values that look like '\u039b \u041e \u0422 \u0422 \u0410' (sequence of '\u0[number][number][number or letter]') how do i ...
0votes
2answers
27views

Why am I getting an error when I try to add a Primary Key?

I am using SQL Server and SSMS. I have a table called PersonsTable: PersonID FirstName Surname Age 1 Hansen Ola 30 2 Svendson Tove 23 3 ...
2votes
1answer
25views

Creating table with insert command to recreate every row

I have table named workerTab: | Id | Name | Age | Cityid | | ---| ---- | --- | --- | | 1| John | 22 | 5 | | 2| Adam | 34 | 5 | | 3| Eve | 19 | 5 | And I would like to ...
0votes
0answers
5views

Job getting account disabled Error, but works as normal when executed manually

The account used in a linked external SQL Server was disabled, by the external server, temporaly. After the restoration of access, various job routines that used this account continued working, as ...
0votes
0answers
22views

nvarchar to date/datetime conversion failing when using sqlconnection but not in SSMS

Is there a difference between running a query with sqlconnection in .NET and running the exact same command in SSMS on the same data? I'm getting different results. To reproduce in .NET, I have two ...

153050per page