t-sql Questions

5

Solved

I have the following (highly simplified) XML document that I am reading into my database using the OPENXML function: <root> <row> <bar>123</bar> </row> <row&gt...
Cannula asked 20/5, 2010 at 21:22

6

Solved

Is there an empty statement keyword in T-SQL in SQL Server 2005 or newer? Something like NULL statement in PL/SQL.
Duplicature asked 13/7, 2010 at 7:9

11

I am trying to import data from Excel 2007 (.xlsx) files into SQL Server 2008 using a T-SQL OpenRowset() command with the "Microsoft.ACE.OLEDB.12.0" OLE DB provider, and I'm getting a persistent "C...
Deposit asked 10/1, 2012 at 2:48

6

Solved

I have a SELECT request with 'inner join' in the joined table is a column with bit type. I want to select 1 if in the joined table is at most one value with 1. If it is not the case the value will...
Outface asked 29/5, 2012 at 17:34

1

Solved

I have a view in SQL Server that calls a function. When I show the actual execution plan for querying the view, what happens inside the function is completely opaque though. As a small example, I m...
Peril asked 10/3, 2023 at 8:48

5

Solved

Is there a way to increase the limit for a nonclustered index which is 1700 bytes in SQL Server? When I build my database I get this warning: Warning! The maximum key length for a nonclustered i...
Coly asked 8/7, 2019 at 13:41

14

Solved

I have a select query that has DURATION column to calculate number of Minutes . I want to convert those minutes to hh:mm format. Duration has values like 60, 120,150 For example: 60 becomes 01:0...

6

Solved

I want to create a new table in SQL Server with the following query. I am unable to understand why this query doesn't work. Query1: Works SELECT * FROM TABLE1 UNION SELECT * FROM TABLE2 Query2...
Wellestablished asked 25/10, 2010 at 20:46

8

Solved

Why is it that in SQL Server I can't do this: select sum(count(id)) as 'count' from table But I can do select sum(x.count) from ( select count(id) as 'count' from table ) x Are they not es...
Haemal asked 25/5, 2012 at 3:3

5

Solved

I need to find the highest value from the database that satisfies a certain formatting convention. Specifically, I would like to find the highest value that looks like EU999999 ('9' being any di...
Metal asked 24/2, 2010 at 21:14

4

Solved

I have a server with multiple databases. I need to loop through these databases and change a value in one record, in one table, in each database. How can this be done?
Rentier asked 8/7, 2010 at 17:28

2

Solved

I am trying to get row count from the following query. I get only row count as 1 but there are 35 records. Could you please let me know how to get the count from inner query? SELECT COUNT(*)(SELECT...
Pandanus asked 3/5, 2012 at 20:50

5

Solved

I have a query to find certain customers from a table. SELECT COUNT(*) FROM CUSTOMER WHERE amount <> 0 AND customerid = 22 There is an index on customerid, so the DB scans all rows with...
Taryn asked 17/2, 2011 at 16:9

13

Solved

I want to update a table with consecutive numbering starting with 1. The update has a where clause so only results that meet the clause will be renumbered. Can I accomplish this efficiently without...
Silicium asked 22/7, 2009 at 20:3

8

The Original SQL Statement is: SELECT SA.[RequestStartDate] as 'Service Start Date', SA.[RequestEndDate] as 'Service End Date', FROM (......)SA WHERE...... The output date format is YYYY/MM/D...
Ozan asked 22/7, 2016 at 8:6

5

I have a database field that contains address information stored as multi-line strings. 88 Park View Hemmingdale London Could anyone tell me the best way to get line 1, line 2 & line 3 as di...
Sheetfed asked 14/11, 2012 at 18:8

10

Solved

I need to know if a given Job is currently running on Ms SQL 2008 server. So as to not to invoke same job again that may lead to concurrency issues.
Ithunn asked 26/8, 2013 at 13:52

3

Solved

I have a table that look something like this value_1 value_2 value_3 --------------------------- 1 2 3 4 5 6 7 8 9 ... ... ... and I need to run a stored procedure for every row of this tabl...
Leisure asked 11/6, 2014 at 7:27

13

Solved

I have an integer column "Month" I would like to get 2 digit number for month. This is what I have tried: DATEPART(mm, @Date) It returns one digit for months January to September I am using SQL S...
Palaeography asked 20/2, 2013 at 9:6

8

Solved

DECLARE @DatabaseName NVARCHAR(max); SET @DatabaseName = 'MainDb' USE @DatabaseName Wouldn't work. How to make it?
Nisen asked 24/9, 2010 at 15:30

4

Solved

I have a SQL select statement like this: select FirstName, LastName, Age from People This will return me something like a table: Peter Smith 34 John Walker 46 Pat Benetar 57 What I want is to...
Rating asked 10/2, 2011 at 23:58

5

Solved

Is there a simple way to view the SQL Queries actually generated by SSRS other than running profile traces to capture them? Is there some way from within the BIDS editor to see this?
Federico asked 9/8, 2010 at 14:36

17

Solved

I want to find all column names in all tables in all databases. Is there a query that can do that for me?
Iow asked 28/4, 2010 at 11:53

6

I want to generate a script to assign a user account to some securables, e.g. Table:Select. How to do this?
Hedgepeth asked 30/9, 2009 at 19:48

9

Solved

I'm looking at the AdventureWorks sample database for SQL Server 2008, and I see in their creation scripts that they tend to use the following: ALTER TABLE [Production].[ProductCostHistory] WITH C...
Rootstock asked 9/2, 2009 at 21:2

© 2022 - 2025 — McMap. All rights reserved.