CARVIEW |
Select Language
HTTP/2 200
date: Wed, 23 Jul 2025 12:30:41 GMT
content-type: text/html; charset=utf-8
cf-ray: 963b30c11e4cc464-BLR
cf-cache-status: DYNAMIC
cache-control: private
set-cookie: prov=e62b2090-ad45-4047-8d31-bfb48c7253ee; expires=Thu, 23 Jul 2026 12:30:41 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-frame-options: SAMEORIGIN
x-request-guid: e6f0dc64-2c20-435e-a0e6-1dfe46f2a1f6
x-worker-origin-response-time: 518000000
x-dns-prefetch-control: off
set-cookie: prov=e62b2090-ad45-4047-8d31-bfb48c7253ee; Path=/; HttpOnly; Domain=stackexchange.com
set-cookie: __cf_bm=NoofIYZ3n_qbkX5s.8v9d6I_TCg2emPvRo2d9DKpuc8-1753273841-1.0.1.1-UiWP2PCRvTnK.BLjG_H2Xsxvg0WpIgzp9RnGdudzzkvlmxc7tXlV8CmJjFkeu5rush8528KmJ2tAtlkJheJ8F5_HyhazyNDaikzDb7lqciM; path=/; expires=Wed, 23-Jul-25 13:00:41 GMT; domain=.stackexchange.com; HttpOnly; Secure; SameSite=None
set-cookie: _cfuvid=d47EW.SfMtFOw1lsmq8YGieRPSmVxpQLA47C7Bptx5Q-1753273841357-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
100
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
154
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
142
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
421
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
613
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
- In QGIS installed via OSGeo4W on Windows 11, what is the path to the command history file for the Python console?
- SOSL/SOQL isn't returning User records
- a stray не in this sentence?
- Why is the number of Marie Curie postdoctoral fellowships in mathematics significantly lower than in other subjects?
- Why Schrodinger wave equation is totally different from classical wave equation?
- Is it rude to make someone an academic reference without getting their permission first?
- Fit text on TWO pages by varying font size automatically
- How should a typical reward curve look like while training a RL model
- Write two very different programs with the same characters
- Is a diet of one third Tuna ok for an eldery cat?
- Repository with SQLite in Python
- Can I still get the pacifist ending if I use the fight option in a boss fight, but miss every time?
- Entity Framework - Is there a safety mechanism to prevent accidentally running Update-Database?
- Is it better to nest figure environments inside proof environments, or leave them separate?
- What is that "T" in the pattern string of the date-command?
- Story about a room on Mars that contains God
- Must hospitals care for unidentifiable individuals indefinitely?
- Is it legal for businesses to give financial incentives for leaving positive reviews on review sites (e.g., Google Maps, Yelp, Facebook, Amazon)?
- Praesul meorum tattoo
- Behavior change in Libreoffice versions after 5.4 pressing Enter below a full-text-width image
- Distribution of a dot product of multinomial variables
- A word that describes some people
- How does Rav Kotler assign final letters in 5 cases in Vayikra-Bamidbar?
- Error when sending an email with attached PDF using Google Script