t-sql's questions - English 1answer

2.143 t-sql questions.

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, ...

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 ...

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 ...

One of my colleagues SSMS recently got updated to 2012 version from SSMS 2008 R2. After that they are view only a few editors in SSMS for adding different File Extensions Tools ==> Options ==>Text ...

I'm trying to achieve the following: California | Los Angeles, San Francisco, Sacramento Florida | Jacksonville, Miami Unfortunately, I'm getting ",Los Angeles, San Francisco, Sacramento, ...

Eval Function TSQL

3 answers, 65 views sql-server t-sql
Is there a TSQL function that allows to validate an operation? Example: Select (1 = 0) should return false while Select (1 = 1) should return true or Select ('a' = 'b') should return false while ...

I have a VLDB with a default setup: a single MDF file in the PRIMARY file group. I want to create a new file group which will contain a few of the most high-capacity or highly trafficked tables found ...

These two queries return the same result (generating a sequence of integers): 1 2 3 4 5 ... 16 What performance/other considerations should be taken into account when choosing one or the other? A (...

The normal JOIN ... ON ... syntax is well known. But it is also possible to position the ON clause separately from the JOIN that it corresponds to. This is something that is rarely seen in practice, ...

Sql Server Database on Azure (Sql Server 2014/12.0.2000.8) I have numerous stored procedures that all had the same basic select properties and joins, so I decided to generate a view that encompassed ...

I have three versions of the same select query (SQL Fiddle here): CREATE TABLE MainTable(ID INT) CREATE TABLE SubTable(ID INT, Type CHAR(2)) CREATE TABLE SubTableType(Type CHAR(2)) INSERT MainTable ...

fairly new to T-sql so please bear with me. I am trying to write a stored procedure that is invoked by application level logic. The stored procedure takes in two parameters, name of a table and number ...

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 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've been working with SQL queries for a couple of weeks and I'm trying to learn and understand from my mistakes. I have a table with two columns IsInvisible (bit) and ShortName (string) and when one ...

I'm currently trying to get an application to use memory optimised tables instead of temporary tables, but have hit an issue. The issue is related to permissions, as users of the application are only ...

I have the full backup of a database, also one differential backup and one log backup. Is it possible to restore this 3 backups together? SSMS lets only full backup and only one of them. Is there a ...

I am working on a query for a project and sometimes the results have multiple rows for the same entity. What I need to do is: If the results look like this: Type | Entity ----------------...

I'm trying to delete all users but getting the error: Msg 547, Level 16, State 0, Line 1 The DELETE statement conflicted with the REFERENCE constraint "FK_M02ArticlePersons_M06Persons". The conflict ...

I want to format a number to display decimal places according to a configuration value specified in another table. If the configured value is NULL, the number of decimal places should default to 2 (...

My syntax keeps giving me the below error, which is blowing my mind as I think (and please kindly correct me if I am incorrect), I have declared and set this variable above. Msg 137, Level 15, ...

I am new to SQL world and I am creating a query in which I want to show SHIP_TO_ADDRESS as well VENDOR_ADDRESS. The driving table ORDER contains ADDRESS_ID for both. All the addresses are stored in ...

I have a static table containing filenames (StaticFilesTbl). Each day a file is sent in that is stored in DailyFilesTbl. The filenames in DailyFilesTbl will be different from StaticFilesTbl in that ...

I have a script which uses a synonym. I have to alter that code and the problem is I can't understand which object that synonym refers to. Is there a way to find out? I am using the original database ...

I need to perform an UPDATE and an INSERT in a single transaction. That code works fine on its own, but I'd like to be able to call it easily and pass in the required parameters. When I try to nest ...

I have designed an sql database to keep historical data of changes. I am tracking either full copy of my object or the change since the last version (very similar to incremental changes). I need to ...

Microsoft SQL Server has a system stored procedure called sp_refreshview which updates the metadata of the view that's passed in. Are there any downsides to running this procedure regularly on all of ...

I am currently using SQL Server 2016 SP standard edition and want to install R services. In the documentation is said that a stand alone installation is allowed only on Enterprise (Machine Learning ...

In MSSQL 2016 enterprise edition I have a table column which can contain an int. I'd like to query for 1000 rows where this column equal X, but if no rows then column may contain any value. Eg: ...

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(...

I have perform some test with relatively small tables and the encryption took a very long time (maybe because there are many SQL objects that are referring the target table). I am wondering(worrying)...

I need to get a result showing each NetworkService that is connect to a Subscription with a number provided in a list and also that is of a NetworkServiceType that has a description that includes the ...

SQL Server contains system functions for viewing / updating string data to both uppercase and lowercase but not proper case. There are multiple reasons for desiring this operation takes place in SQL ...

Is there an ability to query below system specifications using t-sql ? 1. cpu (show number of processors / cores / frequency) 2. memory (show total amount of RAM on a machine; show allocated RAM; ...

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) ...

This is a SQL Server 2014 Server and we have application code the does a Select @@Scope_Identity after an insert into a table. Recently other developers added triggers to this table and ever since, ...

I've created a query which I want to insert the results into another table. It is going to be ran as a job every day, and data imported will still be kept in the result set. I don't want the data to ...

Recently, I was given a task to print all the prime numbers (1-100). I failed drastically there. My Code: Create Procedure PrintPrimeNumbers @startnum int, @endnum int AS BEGIN Declare @a INT; ...

I have a query where I need to add 2 days to the date variable based on a condition. However, this date variable needs to skip weekends and holidays. I have a table that stores holidays. How do I ...

This seems to be an area with quite a few myths and conflicting views. So what is the difference between a table variable and a local temporary table in SQL Server?

We run Dynamics GP, and anybody that's dealt with GP will be familiar with all of its "magic number" columns representing the various enum values inside the application. For example, a reporting query ...

I am trying to create a stored procedure on my Azure SQL Database, which has joins to other database table in Azure SQL Database. I am getting the following error while creating the Stored Procedure: ...

I want to create an alias for a SELECT statement, but then I want to limit the resultset with a TOP clause. If the procedure TopCount parameter is bigger than 0, I want to put limit result set with ...

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 '...

I'm using the following query to view files/folders in a given directory. It works locally, but when trying to view a mapped drive I get... "The system cannot find the path specified." I have the ...

Running SQL Server in fibre mode (lightweight pooling) disables the use of SQL CLR: Common language runtime (CLR) execution is not supported under lightweight pooling. Disable one of two options: "...

I have a value of 100 from a textBox and I want to increment that value in the stock_out column but only till stock_out column is equal to stock_in column, if first row value is 40 than first row ...

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'm trying to write a stored procedure that does the sum calculation on a field using parameters ID and date. For this purpose I have two tables. My table that contains data ID CAF SDATE 1 ...

Related tags

Hot questions

Language

Popular Tags