All Questions
Tagged with sql-server-2005 t-sql
3,413
questions
1
vote
3
answers
1k
views
SQL Query to determine number of tables
I have this table and I'm trying to determine how many Tables (in a restaurant) are awaiting food.
The table( in the database) has the following columns:
TableNumber, ObjectType, ObjectDescription and ...
0
votes
0
answers
71
views
Stored procedure starting with #
I was running a trace on an application today and saw this for the first time ever, in the text data of the trace:
exec #spDMF1F848FB98D743F69BA4AF02A7C05927
Can't seem to find anything online ...
1
vote
2
answers
4k
views
Modify SQL_Variant Column to VARCHAR
I have a table where one of the columns has a sql_variant datatype. I'm trying to modify the column to VarChar(800) but I'm getting an error:
Implicit conversion from data type sql_variant to varchar ...
0
votes
3
answers
713
views
SQL - Remove pattern from varchar string
One of our applications was appending notes to the end of one of our columns, we have now removed this from the app and wish to remove existing from the data.
I have a pattern within Varchar (2000) ...
0
votes
1
answer
1k
views
How to get table's metadata from linked server (SQL Server)
How to get tables metadata from linked server/another database? The query below works ideally when running on the main server, but returns null if calls remote server or even another database.
select ...
1
vote
0
answers
58
views
XML Parsing in SQL
I have to parse the below xml query
DECLARE @xml XML,
@Columns VARCHAR(MAX)
set @xml='<d><record1><columnA>1</columnA><columnB>as</columnB><columnC&...
0
votes
2
answers
73
views
Occurrence in MS SQL Server
create table #Task (ID int, Name varchar(1), Occurrence int)
insert into #Task values (1, 'A', 2)
insert into #Task values (2, 'B', 3)
insert into #Task values (3, 'C', 1)
insert into #Task values (4,...
0
votes
1
answer
151
views
How to run CRUD in single procedure by using json?(T-SQL)
Procedure
ALTER PROCEDURE [dbo].[SpProductTsk]
(@json varchar(MAX))
AS
----insert---
BEGIN
DECLARE @SelectedProcedure varchar(max) = ''
IF @SelectedProcedure = 'SpProductIns'
...
-1
votes
2
answers
380
views
How to compare two date values in SQL Server?
I have a table with the date 2018 and date 2019 and here is my data.
select amount, date
from TABLE1
where date in (2018, 2019) and empid = 21120
It didn't work for me as the query says case when ...
-1
votes
1
answer
52
views
T-SQL date between query
What is the most efficent way in T-SQL (2005) to get results from X date til today?
Attribute is RegistrationDate and is in date/time format, such as Monday, July 15, 2019 12:00 AM
I'm looking to ...
0
votes
1
answer
263
views
SQL Server INSERT-OUTPUT including column from other table
I need to insert data into a table and I need to output the newly inserted ids from the destination table mapped alongside the Ids from the source table.
I have the following query:
DECLARE @mapping ...
3
votes
1
answer
2k
views
T-SQL: An error occurred while executing batch. Error message is: Arithmetic Overflow for select * from MyTable
I'm doing a simple query like this:
select * from MyTable
This results in the following error:
An error occurred while executing batch. Error message is: Arithmetic
Overflow
I can run select ...
0
votes
2
answers
2k
views
Select from table where ids are not in list of ids
I'm trying to select from a table where the primary_no (VARCHAR(20)) does not include any of the strings in the @IDS variable, but it's not working and I have tried using a CTE, not exists and not in. ...
0
votes
3
answers
7k
views
T-SQL query to get a date +30 days from today exactly
Data is in date/time format and I'm trying to get list of rows where the date is exatly in 30 days from today. This is based on SQL Server 2005.
So on 1st of July, I would get a list of rows where ...