Quantcast
Channel: Transact-SQL forum
Browsing all 12890 articles
Browse latest View live

How to write a transact-sql query which selects a specified quantity of...

Hi, retired hobby coder newly working with sql server.  I need some help writing a query in sql.  I'm sure it's pretty basic but I can't figure out how to write the transact-sql.I have a sql table with...

View Article


SQL Query to list details by Age

Hi All,I have a Tenant table and want the query to list all tenants in Age bracket between age 14 and 24. But since we have the mobile no of the main tenant we also want to show their record as well....

View Article


OBJECT_ID for a PK or Index

Hi friends,With a need for the first time to check if a PK and an Index exists before dropping and re-creating the same need your help.IF OBJECT_ID(N'PK_LMT', N'PK') IS NOT NULL SELECT 1 (does not work...

View Article

Complex tsql query

  Hello, This is related to a company buying query.Create table #company(Name VARCHAR(10),CompanyProfit INTEGER,EffDate DATE,EndDate DATE,ReplacedCompanyName varchar(10)) Insert into #company values...

View Article

Image may be NSFW.
Clik here to view.

Need help updating records from a subset yielded by a subquery.

Hi, retired, hobby coder needing (further) help in transact-sql scripting with a view to creating a stored procedure within a Sequel DB.  For the purposes of this investigation I have a table with 23...

View Article


Understanding db_securityadmin role

Could someone please explain me the underlined sentence with an exampledb_securityadmin - Members of the db_securityadmin fixed database role can modify role membership and manage permissions.Adding...

View Article

CASE statement tuning

Hi All,Am very new to query tuning, As first step am trying to tune a view in test environment.. On checking the logical reads case statement did 92% of logical reads though the table is just 3 rows,...

View Article

Create XML format file in bulk insert with a data file with out delimiter

Hello I have a date file with no delimiter like bellow 0080970393102312072981103378000004329392643958 0080970393102312072981103378000004329392643958 I just know 5 first number in a line is for example...

View Article


Query to find basic salary

Hi ,I need to find basic salary of all the employees from their actual salary10% of his basic salary will be debited at the end of the month If the employee is about to relieve the company ,he should...

View Article


Managing concurrency in Stored Proc with Timestamp

Hello all,I am trying to find the right way to get the correct error reported in a Stored Proc where the table contains a timestamp column. I gather the TSEqual is not the way to go (I'm using SQL...

View Article

How to create a temp copy of the current used database

I have the following use case: - Create a database from the current used database. - Use or switch to the created database. - Return to the main database (ignore, delete, throw the created database)....

View Article

Query Question

Removed post

View Article

Why Does This Query Return Results?

This is a small subset of my actual data-set, but from my point of view it should be excluding all records from #Source, since neither option1 or option2 are null in #Destination.  Can someone explain...

View Article


Image may be NSFW.
Clik here to view.

pivot function with duplicate data

Hello, I have a table        drop table #a       create table #a(lvl integer, id integer,roomno integer)       insert into #a values(4,8,5)       insert into #a values(3,7,6)       insert into #a...

View Article

Image may be NSFW.
Clik here to view.

Query Help

Select dateadd(month, 6, Csat.InterviewDate)as DueDate,csat.Interviewdate,csat.interviewtypecode,csat.clientid from rpt.csatclientdcilegacy as CSAT Inner Join rpt.VwAssessment AS ast ON...

View Article


TSQL date convert "MMM/yyyy" format

how can convert date to  "MMM/yyyy"   TSQLplz help

View Article

calculate date differences in consecutive rows and generate a sequence

Hi Guys,I am trying to implement one scenario where in i need to compare the date differences for consecutive rows and generate a sequence against that.this is the table schema:create table temp(id int...

View Article


How to identify when there is a break in continuity of an integer

Hi guys, Can you give me an idea on how to solve the following issue?column01       column02       column03       column04      1                    001                 002                  0...

View Article

Help Joining extra view to query

Hi, I am using this query to get the installed SQL version information form ConfigMgr.http://www.hasmug.com/2014/06/29/improved-reporting-on-sql-instances-in-sccm/ The query on it own works like a...

View Article

subtract negative number given positive number

I am trying to subtract 2 items  rev - cost. But some cost are negative numbers and therefore and therefore causingrev- (-cost) becoming rev+ cost causing big number answers.0- (-cost) becoming rev+...

View Article
Browsing all 12890 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>