t-sql's questions - English 1answer

2.207 t-sql questions.

I have 2 table in my database. Table #1 ------------------------------------------------------------------------- | name | family | phone | email | gender | phone2 | address | birthdate | -----------...

I am working on a report, one of the requirements is that I find the turnaround time between two dates (columns) - I have done that using a DATEPART function, however, the hours are exaggerated, I ...

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 need to know why the correct answer is D ? what is the diffrence between D and A. Your database contains a table named SalesOrders. The table includes a DATETIME column named OrderTime that stores ...

I will need to allow report writers on the Subscription database to be able to view the table, create alter and delete stored procedure and views. Since it is a transactional replication they cannot ...

I have a table Client. There are two columns Name and FathersName. Now I need to check these two fields at the time of insert, the combination of these two fields shouldn't be repeated. The possible ...

I have a table inventory_receipts_line_ud inside which there is a field item_mast_uid which is a key and also a field named prop65 which is a 'Y'/'N' field. I also have a table inv_mast_ud inside ...

Given this set... Site, Date 4 10/10/18 3 10/10/18 4 07/10/18 5 12/10/18 3 11/10/18 5 13/11/18 I want to order it such that the rows are ordered by site and the site groups are ordered ...

Scenario: I have a table with 100M+ rows of data so I have created an index with something as: CREATE NONCLUSTERED INDEX FIBaseVoterWithDeletedAt ON dbo.base_voter (name_voter,...

Sorry if this question is very basic, but I just can't figure it out, and couldn't find any good answers. I have a very long list of files, folders and Sizes. I need to Seperate the folders to ...

I have used DBCC CLONEDATABASE to create a copy of a database without any data. I have now found that some schemas were not created, thus some objects have no schema. Its hard to reproduce this as it ...

I have a stored procedure that basically selects values from one table and inserts them to another, a sort of archiving. I want to avoid multiple people from doing that at the same time. While this ...

This is my query ALTER Procedure [dbo].[OpenExcel] @FileName Varchar(2000), @ExcelName Varchar(2000), @SheetName Varchar(100) , @Header Varchar(50) , @...

I have an Excel File with Persian (Farsi) headers and I'm using OPENROWSET to read the data from the excel file. The problem is that when I mention the name of the columns , the function does not ...

I have one "Execute SQL task" in which I've written this query : Declare @STR nvarchar(Max) ='';Select @STR = @STR + [ExcelFieldName]+' ' + 'AS'+' ' +[TargetFieldName] + ','From [dbo].[TargetDetail] ...

Many times I need to write something like the following when dealing with SQL Server. create table #table_name ( column1 int, column2 varchar(200) ... ) insert into #table_name execute ...

I need to write a Table - valued function from which I can acquire a table result set with different structure each time. another thing is that I need to declare variables inside my function . I've ...

I am trying to get data using offset limit concept as follows: CREATE PROCEDURE BaseUserIndex @Offset int, @Limit int, @SortCol int, @SortDir nvarchar(10), @Search nvarchar(255) = ...

I need to have a where clause in OPENROWSET but it is not always fix. It might be null sometimes. I have a procedure as you can see here : ALTER PROCEDURE [dbo].[OpenExcel] @TableName VARCHAR(2000) ...

We are having much troubles on our ETL project in SQL Server 2016. The project keeps hanging on different tasks. After searching for possible solutions in the web I found that, in order to increase ...

can we get an output for list of databases which were not modified for last two months in a server and based on that we have to delete all of them. I have tried below is the query: --identify when a ...

I have a table with records and their scores (table 'Offers'): OfferId OfferScore ----------- ----------- 1 1 2 20 3 3 4 4 5 5 6 6 7 ...

I face a problem while writing a stored procedure. I want to write a stored procedure so that it gets 2 input parameters (Date and TableName) and then delete table rows which Date column of the table ...

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

In my SQL Server database, I have a datetime column. What is a good way to create a new column that represents the long value for the datetime column. The long would represent a number of seconds.

I'm testing a new setup that we're hoping to deploy in our small shop: using SQL Server on Windows, but connecting the database to a Linux SMB share. I'm using the latest SQL Server 2017 Developer ...

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 am writing a custom JSON parser in T-SQL†. For the purpose of my parser, I am using the PATINDEX function that calculates the position of a token from a list of tokens. The tokens in my case are ...

Hope you are doing well. I have a procedure as you can see below : ALTER Procedure [dbo].[OpenExcel] @TableName varchar(2000), @FileName varchar(2000), @ResultOpenExcel tinyint output AS ...

I am reading a book which shows this example SELECT wait_type , SUM(wait_time_ms / 1000) AS [wait_time_s] FROM sys.dm_os_wait_stats DOWS WHERE wait_type NOT IN ( 'SLEEP_TASK', 'BROKER_TASK_STOP', '...

I am putting a script together, that gives me the permissions on database objects. SELECT permission_order=710 ,permission_type = 'Object Level Permissions' ,db = db_name(), login_=...

I have a stored procedure that searches for rows given a long list of parameters. Some of the queries result in extremely slow count queries. Is it possible to stop counting after, say, one hundred ...

I'm trying to write a Dynamic query to pass file name and table name to the procedure dynamically. what is wrong with this query? ALTER Procedure [dbo].[OpenExcel] @FileName nvarchar(2000), @...

I have two tables in a SQL Server Database, StudentAttendance and Attendance with the following structure: Attendance AttendanceID TimeTableID AttendanceDate UserName StudentAttendance ...

I was wondering if you could tell me what is wrong with my query? The parameter @TableName is an input parameter. Why do I have to declare it again? CREATE PROCEDURE [dbo].[OpenExcel] @FileName ...

Hope you are doing well. I need to insert data from different Excel files With different structures Into different tables in my database. So according to this scenario I can not use 'Data flow task' ...

I can't understand why is dbo the only grantor in SQL Server? Or am I wrong? I mean it as follow: No matter as which user I am currently loged in in SQL Server Management Studio, when I go to ...

I have a query that returns records with duplicate Month and Year in a date field. I need to identify the records with duplicate Month and Year, then identify the oldest based upon the full date and ...

I have used SQL Server a fair amount but always with SSMS. I would like to be able to use all the capabilities and understand the environment better but I do not know where I use T-sql. I have tried ...

Is it possible to find the size of data that will be returned by a particular query? For example, I can use the following to find the number of rows per date: select mydatecolumn, count(*) from ...

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

I want to use a parameter within where clause only if it's value is provided by strongly typed dataset, this is what I am trying at the moment, I get right results when I provide parameter3 and no ...

I've looked at this link, but it does not really answer my question. Developing a Function for this would be ideal. I developed a trigger to insert the following into a table using one column: ...

It is easy to demonstrate that many date/time formats other than the following two are vulnerable to misinterpretation due to SET LANGUAGE, SET DATEFORMAT, or a login's default language: yyyyMMdd ...

I have a very basic question: I have this code which works and returns me 23 rows: select Issue_ID ,sum(HoursSpent) as TimeSpent --,DateClosed from SixMonthsReview where StaffAssigned = 'Teddy ...

I am migrating from Oracle to SQL Server using SSMA and I get thrown an unparsed SQL error on the below code. Can anyone help me convert this to T-SQL? Thanks in advance. CREATE OR REPLACE TRIGGER "...

How can I display legends name on a column chart itself in SSRS?

I have table with following structure. and I want to generate a row per day and a column per combination of first and second level category. The output should be like: Can anybody help me out in ...

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

Declare @bst varchar(1000), @pst varchar(1000), @ost varchar(1000), @t_cnt int = 1; WHILE @t_cnt <= (SELECT count(*) FROM t_temp) BEGIN SELECT @bst = g_Search_Text FROM t_temp WHERE id = ...

Related tags

Hot questions

Language

Popular Tags