t-sql's questions - Chinese 1answer

2.172 t-sql questions.

First off I apologize for asking a question I'm sure is well answered, however I cannot quite understand what I'm reading. I have an existing table with an xml column. I have a second table with the ...

I have strange problem, I have 3 SQL Server 2012 with Sp1 instances, and on all of them, the versions are identical. I am trying to query Active Directory services, on 2 of them this is working ...

I have a table like: ID A0 A1 A2 A3 A4 14 A B A C A 15 A A A A A I need to compare all 5 columns and check if they have same value and retrive the only one that have all same ...

Using temporal tables one is able to use the FOR_SYSTEM TIME clause with combinations with other options to get valid rows for specific time intervals. For example, we have: FOR SYSTEM_TIME ALL FOR ...

I've a situation where I have two databases: ABCData ABCUsers One of the stored procedures in ABCData needs to perform an insert to a table in ABCUsers. This could just be hard coded: INSERT ...

I use the following statement to monitor activity in SQL Server (This is out of some book) SELECT des.session_id , des.status , des.login_name , des.[HOST_NAME] , der....

I'm trying to find out the position of each given record of a query in 0-100 scale. I use PERCENT_RANK ranking function this way: select Term, Frequency, percent_rank() over (order by Frequency desc) ...

All of my tables have those two columns: [Id] [uniqueidentifier] NOT NULL [Revision] [bigint] IDENTITY(1, 1) NOT NULL Every other time I write a query, I want to eliminate some of the rows. The ...

We have 3 primary tables A, B and C. We also have three secondary tables X, Y and Z. The business rule is: if there is any record of A or B or C, then there must be A and B and C, and also X and Y ...

When I run sp_spaceused dummybizo I get the following results: name rows reserved data index_size unused dummybizo 0 72 KB 8 KB 8 KB 56 KB I am expecting the ...

I am wanting to compare the Distinct sn from HMI_Temp to sn in my table HMI -> if the sn exists, I want to update the values - got this syntax CHECK! - if the sn does NOT exist, I want to insert the ...

I have a value in a SQL table like the below: 80400365_SwapOpenTrd_20180831.csv I want to replace the numeric values so it is returned as this: %_SwapOpenTrd_%.csv I tried the below code but there ...

I have a query where a row is selected when field1 <> 10. When field1 is null, this predicate is false! According to my primitive maths, if null <> 10 = false, then 10 = null. What is ...

In a place where I work we have lots of subscriptions set for SSRS reports. Some reports have as many as 100 subscriptions set up. Our data warehouse is refreshed every night, with all the data ...

i am trying to query without success, what i am trying to do is that ALTER PROCEDURE [dbo].[spPagination] -- ORDER BY id @filterCol NVARCHAR(20) = NULL, --<<<< @filterValue NVARCHAR(...

Apologies if this is a stupid question. We are attempting to convert our multi-statement table valued functions (MSTVFs) to inline table valued functions (ITVFs), to avoid the forced serialization of ...

I have a few users that are unexpectedly receiving this error message today when they attempt to refresh a stored procedure via Excel: The EXECUTE permission was denied on the object 'SPROC', ...

I would to hear the solution for the below requirement. I have table A with key number and Fruits, table B with Fruits and rating with the below data. I have to retrieve result with least rating ...

I have a column that contains numbers: Value ----- 123 452 021 111 ... I want to get the sum of each value's digits. Answer should look like Value SumValue ----- -------- 123 6 452 11 021 ...

I executed a script that had multiple sections, separated by the GO command, something like this: Use DB1 GO ALTER TABLE foo ADD bar VARCHAR(10) NULL UPDATE foo SET bar = 'nananana' ALTER TABLE foo ...

As the title states, I have a recursive CTE that bombs out when I change the operators in the WHERE clause, even if there are only two rows of data. CREATE TABLE #Recursion (Parent varchar(10), Child ...

$sql = "SELECT Kill FROM tbl_pvporderview"; Problem is that I end up with: Incorrect syntax near the keyword 'Kill'. Because kill is a T-SQL command... any way to bypass it? I can't change the ...

I need to pull out the list of stored procedures which are available in my instance. I used the following T-SQL statement to get the stored procedures in a given database. select * from MyDatabase....

We've been querying and processing a growing table of events in our system, which was fine without specific indexes for now. However we've noticed a decrease in performance and are wondering what we ...

Usecase: MSSQL Database is hosted in the cloud, I download the database thrue FTP and restore it on-premise automatically for reporting. Now I want to retrieve the date/time when the backup was made, ...

Is there a way to do a full-text search using words stored in another table? This is my scenario: Table_A contains phrases entered by users in field "UserInput" (and other stuff). I have a full-...

Can anyone help me on below scenario I need small help on group by state ID Below is my query and I am tried to get all the out put in single line . But I am getting different lines for each year . ...

I have a database in standby mode. -- STEP 1 -- Restore path F1 > T7 RESTORE DATABASE [TestRestore] FROM DISK = N'C:\Temp\F1.BAK' WITH FILE = 1, NORECOVERY, NOUNLOAD, REPLACE, STATS = 5 GO -- ...

I have a table like below: How can I have a column like below using Transact-SQL (Order By Date)? I'm using SQL Server 2016.

I am attempting to query a maximum of 65,000 records in a database (minimum of 0). The server is using MS SQL Server 2014, and I have no way to change the hardware on the server. Schema [Id] (PK) ...

Let me explain my case. I have a mount with database files on my local PC. I attach the database (from this mount). And then close this mount (in other word i attach db and then delete db files). So ...

I have a stored procedure that executes a simple insert transaction with a try/catch block. If the transaction is successful, OUTPUT will return the inserted record ID. If an error happens, I would ...

MS-SQL 2008 R2 (Dell, 2 CPU) This query takes two minutes to run, which is too slow. SELECT * FROM t_events WITH (NOLOCK) WHERE order_no = 2783190 and event_no <= ( SELECT MIN(event_no) ...

I'm looking for something I can use in Microsot SQL Server that would act the same way the stoi function in C++ acts. Specifically, I'm looking to be able to grab numerics at the beginning of the ...

Morning, All - I'm currently working on some SQL logic, and wanted to get some input on it. What I'm trying to accomplish is the following (Psuedo-code): When a record is inserted into Table A - IF ...

Is there a way to get the affected row count, when updating through an connection server? I'm using MSSQL connected to MySQL with ODBC. UPDATE OPENQUERY (MyConnection, 'UPDATE recordid, status FROM ...

Can anyone please help me on below to get the consolidated ServiceID with the sum of File Size associated with it over an year. Complete Code (For reference) If(OBJECT_ID('tempdb..#temp1') Is Not ...

(NB I don't count as a db admin... I'm just using one, so please assume zero other knowledge) My reference date is '02/04/2017 18:00:00.124', and for no particular reason, whilst I need the time ...

We have a goofy process (don't we all?) that daisy chains (or cascades) on a table that needs flattening out for our data warehouse. The field "alt_key" is an identifier field. It ends up being the ...

I was reading an article at www.codemag.com/article/1208111 and saw cases in the WHERE clauses where columns were compared with Column1 <<<>> Column2 And Column1 <<<= ...

I'm using SQL Server Management Studio 17.4, which supports search-and-replace using a Microsoft version of regular expressions (regex). I need a regex expression that can reliably remove square ...

I am having some trouble while migrating data from SQL Server to MySQL--it seems some data does not want to place nice. I am recieving the error: Incorrect string value: '\xA0\xA0' for column '...

Suppose I have a table with a unique column and this columns has only integer numbers. Eg: ID column with rows from 1 to 999. My intention is to return only rows when my ID is greater than 500, for ...

Reviewing this question it seems like that's a lot of work that shouldn't be needed. They're trying to extend a range with a date. In other databases, you would just use greatest and least.. least(...

We have a simple T-SQL script file (.sql), which we execute through Powershell. Everything works fine, except the script portion, where we are using some special characters as string (example: 'รด' ). ...

I struggled with how to ask this question. This is from a piece of software that we have used for well over a decade. For the life of me, I can't figure out why it works. There are 3 objects in ...

I assume that SELECT HAS_DBACCESS('database name') is equivalent to SELECT HAS_PERMS_BY_NAME('database name', 'DATABASE', 'permission name') for some permission (or set of permissions, the results ...

I have this scenario. Data files are transferred from multiple stores (transactions) to the head office as they happen. For each store the table in question is pretty big in size. At the head office, ...

For one report I am making query where users suppose have to choice TOP values based on percents or fix amount of rows. I have two ideas Calling two different sub stored procedure based on passed ...

I have a table that contains 320,071,712 number of records, the report that I am currently working on can filter the records by date, after which the number of records comes down to 145,878,852. The ...

Related tags

Hot questions

Language

Popular Tags