CARVIEW |
Select Language
HTTP/2 200
date: Thu, 24 Jul 2025 07:41:45 GMT
content-type: text/html; charset=utf-8
cf-ray: 9641c6e50a85b22e-BLR
cf-cache-status: DYNAMIC
cache-control: private
set-cookie: prov=421a8aff-e692-4c8a-8cc0-07cfa43d7056; expires=Fri, 24 Jul 2026 07:41:45 GMT; domain=.stackexchange.com; path=/; secure; httponly
strict-transport-security: max-age=31536000; includeSubDomains
vary: Accept-Encoding
content-security-policy: upgrade-insecure-requests; frame-ancestors 'self' https://stackexchange.com
x-clacks-overhead: GNU Terry Pratchett
x-frame-options: SAMEORIGIN
x-request-guid: 6c978cd3-a734-4202-87bf-51f2f968041b
x-worker-origin-response-time: 504000000
x-dns-prefetch-control: off
set-cookie: prov=421a8aff-e692-4c8a-8cc0-07cfa43d7056; Path=/; HttpOnly; Domain=stackexchange.com
set-cookie: __cf_bm=eujOMxbjeNu5sGVvtG9nHZFOtRcPQP5UsIhw5VT8Ei0-1753342905-1.0.1.1-W3evF8_x4PqOlMG7iFluVvqdgyUcUtAb6K6Sj3BmGWcRW3FMCtvdgj2eHBAX1gOiyliB4P2bEkFP3Khz5.Z2t448joFzVXdfnRPB23KawYg; path=/; expires=Thu, 24-Jul-25 08:11:45 GMT; domain=.stackexchange.com; HttpOnly; Secure; SameSite=None
set-cookie: _cfuvid=opVvKTY5JjGoATaOTvw8IaBoijEuT6.d0ThQYVhE1zg-1753342905643-0.0.1.1-604800000; path=/; domain=.stackexchange.com; HttpOnly; Secure; SameSite=None
server: cloudflare
content-encoding: gzip
Newest 't-sql' Questions - Database Administrators Stack Exchange
Skip to main content
Stack Exchange Network
Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack ExchangeTeams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about TeamsQuestions tagged [t-sql]
Transact-SQL (T-SQL) is a dialect of SQL used by Microsoft SQL Server and SAP's Sybase.
3,120 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
1
answer
48
views
sp_executesql with ISNUMERIC(@ColumnName) not working with column name passed as parameter
Question: Why example 1 does not work while example 2 works:
SQL Table to check for non-numeric values in varchar column:
CREATE TABLE #t(Mycol varchar(15))
INSERT #t VALUES ('123.86'),('4a5.67'),('45....
0
votes
1
answer
102
views
SQL CASE statement ELSE block usage for inserting a record
The last line of the following code inserts records from #S to #D if value is a valid date; otherwise it returns NULL (since I am not using ELSE clause):
CREATE TABLE #S(COL VARCHAR(15))
INSERT #S ...
1
vote
0
answers
76
views
Is it possible to make a batch of “Alter procedure” that are stored in a table?
Currently I have hundreds of sp that are in multiple servers, and that coexist with other sp that are in other servers with linked server.
The origin of this is that when I do a restore of databases ...
0
votes
2
answers
157
views
Grouping and arranging data using FOR JSON PATH and INCLUDE_NULL_VALUES
I'm having an issue with my T-SQL script. I am thinking about and working on how to produce the expected output from it.
Here's my T-SQL script:
DECLARE @user_id VARCHAR(50) = 'UGUID-2025-01-27-14-09-...
1
vote
1
answer
143
views
Multiple UPDATE and INSERT statements using BEGIN TRAN with customized COMMIT TRAN and ROLLBACK TRAN
First things first, since I am using SET XACT_ABORT ON. If an exception happens in any of the INSERT or UPDATE statements within the transaction block, then it should terminate and roll back the ...
4
votes
1
answer
422
views
Is it possible to extract the formula or expression of a field within a SQL Server Stored Procedure?
I have a stored procedure that contains a single select query. Within the query, there are a few aliases that represent a formula or expression.
Is it possible to extract the calculation / formula / ...
18
votes
2
answers
2k
views
Why SUM function returning 4 decimal places, but AVG function returning 6 decimal places
Question: Why SUM is returning with 4 decimal places (as expected), but the Avg is returning with 6 decimal places?
CREATE TABLE #t(Col DECIMAL(19,4))
INSERT #t VALUES (123456.1200),(654321.3400)
...
0
votes
1
answer
87
views
Database user must display only one database and one schema
I have a server on which there are 5 databases: A, B, C, D, E.
I need to create a new schema on database A called ‘rpt’. Then I need to create a new user called ‘usr_rpt’.
This user must have these ...
Simone
1
vote
1
answer
103
views
Convert numbered variables into a table row
I'm working with a legacy system where a stored procedure is called and dozens (literally) of variables are passed in. The data needs to be processed the same way but currently I have to copy/paste ...
0
votes
0
answers
47
views
Inserting range of IP's into a sql table [duplicate]
I have a sql table with two fields TermID and IP address. I want to insert(10.100.08.01-10.100.08.254) and each IP will have an assigned TermID for example (TERM1 - TERM254).
I will greatly ...
-1
votes
1
answer
111
views
Stored Procedure always returns null when using "RETURN value". If I use "SELECT value", it returns value correctly
USE [FPY]
GO
/****** Object: StoredProcedure [dbo].[insupd_tblMRBHistory] Script Date: 2024-12-19 7:25:36 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[...
3
votes
6
answers
614
views
Data sanitation options on INSERT or UPDATE
The answer in this post is pretty much what I did to get my problem:
SQL Server trigger before insert or update depend on value
I have a CUSTOMER table that has multiple triggers attached. One of ...
rsouthern
0
votes
2
answers
102
views
Handling Null in Dynamic SQL
I am trying to capture the existing CDC value and disabling and enabling again for partition truncate. I could not figure out how to handle null values in dynamic SQL.
If I directly pass @role_name ...
0
votes
2
answers
79
views
Query to flag user: SQL2022 Update is needed
My software, compatible with all versions of SQL2016 and up including SQL Azure, crashes when SQL 2022 is lower than Version 16.0.1135.2 or lower than 16.0.4165.4 - depending on RTM, GDR, CU (which I'...
1
vote
2
answers
67
views
Sql Server: Query to parse and validate codes
We have a #ValidCode table with list of valid codes like: 'A', 'B', 'C', etc. Another table called #SourceData with input data -- that comes as a combination of valid and invalid tokens (sometimes ...
- The Overflow Blog
-
-
- Featured on Meta
-
-
Related Tags
sql-server × 2512
sql-server-2008-r2 × 354
sql-server-2012 × 270
sql-server-2008 × 209
stored-procedures × 156
performance × 154
sql-server-2014 × 153
sql-server-2016 × 151
query-performance × 109
ssms × 80
query × 70
join × 62
trigger × 59
index × 57
dynamic-sql × 56
sql-server-2005 × 55
execution-plan × 53
update × 50
optimization × 48
pivot × 45
database-design × 44
azure-sql-database × 40
sql-server-2019 × 39
functions × 38
sql-server-2017 × 36
more related tags
Hot Network Questions
- Can one engage with physics (or science) without touching philosophy?
- How much power does the Fed chair have over interest rates?
- Does Philosophy Need Quotes?
- Is buying random stocks and then selling off the ones that go down a good way to reduce capital gains tax?
- What fiction genres do literary agents recognize?
- How to expand an algebraic function like √R(x) into a continued fraction in Mathematica?
- In this video why are the astronauts wearing only their flight suits during dragon training while in others they are in their full starman suits?
- Camera Controls Stopped Working
- Can you yaw an airplane by only using differential thrust?
- Business technical issues lead to unsuccessful payment being considered successful. Do I have any duty to notify?
- Did Germany declare the Donetsk People’s Republic to be a terrorist organization, at some point?
- How to model This Twisted Torus?
- How can I automatically replace curly braces { and } in LaTeX macro arguments—e.g., in math formulas—for label generation?
- Huge Difference in Interaction P-values Between Linear vs. Ordinal Regression (0.991 vs. 0.001)
- How to get most recent common ancestor of a set of tips using ape package in R?
- Why is `&self` allowed in the parameters of `&mut self` methods, but not `&mut self`?
- Is it okay to email researchers if I’m just a high school student?
- A word that describes some people
- Do standing sound waves sound different?
- Can authors be blacklisted by academic publishers for multiple rejections without any ethical misconduct?
- Macro Definition Outside Current Group
- How do mechanical gyros maintain rotational speed?
- tac-command is it a bug or a misinterpretation of the manual?
- How to 'scale' a square list?