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

update columns in Table A based on columns in Table B for more than 500K rows

Guys,I need to update 9 columns in table A based on value from table B for for more than 500K rows.So what is best way to achieve this. I am thinking of writing a Procedure with cursor to update the...

View Article


Create a ID fore each row inserted into a table during a join without it...

I have a query that updates a table using a table valued parameter so that I can update a number a rows at the same time based on the table valued parameter. I also need to generate a number for every...

View Article


Date Convert

The below is returning 201402011 but I now need it to return date time:LEFT(CONVERT(CHAR(8),DATEADD(MM,-1,GETDATE()),112),6)+'011'How should I edit?

View Article

Null behaviour on SQL 2008

Sorry guys, is there anyone who can explain me the null behaviour on SQL 2008? I mean, I got this selectselect customername, contract, CONVERT(varchar(6),settlementdate,112) as per, sum(consumption) as...

View Article

Access Code - DELETE Statement with DISTINCTROW and T-SQL

All,I'm trying to rewrite Access Code to T-SQL Code. I understand how DISTINCTROW works in a SELECT statement but I'm not sure of the same in a DELETE statement.Any ideas?DELETE DISTINCTROW...

View Article


2 joined crosstabbed tables creating triplicates

What I am attempting:1.Cross-tab 2 tables that contain Monthly Sales (the original text file has a column called month and lists by month. Theend user needs to view by month going across )2. Join Both...

View Article

Calling a common Stored Procedure from multiple stored procedure performance...

Hi,A common procedure is called inside the  multiple stored procedures based on different parameter values.Some times it gets dead slow.Could you please provide the best solution for that.Example:->...

View Article

Why the more powerful server writes data slower than the less powerful server ?

We are using SQL Server 2012. The same database myDB (Simple Recovery mode, Autogrowth by 1000 MB on the data, and by 100 MB on the Log) exists in 2 different servers, server A and B. Server A...

View Article


splitting column

declare @a varchar(50)='$400 per FBD' Select @asometimes the column value is like thisdeclare @a varchar(50)='$2000 x FBDs /5' Select @aAt the end I'm interested in seeing like this amount   Divider400...

View Article


How to insert past record after updating the master table in history table...

Master Table Party Status A Active B Inactive C Active D Inactive Duplicate Table Party Status A Active B Active C Active D Inactive Updated Master Table Party Status A Active B Active C Active D...

View Article

Bulk Insert file into varbinary data

Have a file of EBCDIC data that I want to load into a SQL table. Each  logical record is 247 in length.  i want to read 247 bytes from the file and load as a row into my generic varbinary(4000) column....

View Article

Attempting to select a range of values using wildcard & between or logical...

Hi Everyone,I am in the midst of writing a query to return a range of product BIN LOCATIONS from a warehouse stock levels program.I know the start and end BIN LOCATIONS for the warehouse, e.g.: Start -...

View Article

update statment using function

Environment: Win7 and SQL server 2008 R2 Tools: SQL management tool 2008 R2Problem: I have been trying to update id numbers in the staging table. T-SQL statement updates all id number in the staging...

View Article


Count Distinct Over Partition Syntax Error

Count(Distinct [field]) over (partition by [field2]) returns a syntax error at the key word distinctCount(all [field]) over (partition by [field2]) compiles fineI am writing a query to count the number...

View Article

Display streak

Hi everyone,Env : SQL Serveur 2008 R2I want to build a standing with the "actual streak" (Winning or losing) for each team. I have created a small table with random results in it. Really similar to...

View Article


I want to know will it increase the space of my index drive also?

If I index rebuild online  then log file is growing...I want to know will it increase the space of my index drive also?Thanks

View Article

Trouble with joining based on various combinations of columns

HiI have a load of transaction data which I need to join to a rate table to find the correct rate to price on. The join should be one-to-one and the selection of the correct rate is based on various...

View Article


need a query if it matched update as an alias else leave as it is?

Master Table Party Name PartyID A 112 B 113 E 114 F 115 Duplicate Table Party Name PartyID A 112 B 113 C 114 D 115 Updated Master Table PartyName PartyID Aas Alias 112 B as Alias 113 E 114 F 115I have...

View Article

Deleting all tables in a schema

I am trying to delete all tables in a given schema. Any ideas how to do this via t-sql appreciated.tia,edm2

View Article

how to return null values in a query

Hi All, I have this following query  SELECT        (ct.amount) FROM            dbo.card AS c WITH (NOLOCK) INNER JOIN                         dbo.card_transaction_log AS ct WITH (NOLOCK) ON ct.card_id...

View Article
Browsing all 23857 articles
Browse latest View live


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