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

Query is dead slow

declare @search varchar(100)select id,name,grade from VCustomer(10 million records)where cast(id as varchar) like @search +%here id is bigint and cast operation used in where condition so query is...

View Article


How to debug bulk insert?

I have this code which doesn't cause any error, and actually gives message 'query executed successfully', but it doesn't load any data.bulk insert [dbo].[SPGT] from...

View Article


Performance efficient function to strip punctuation marks

Hi,We are looking at a scenario of stripping a set of columns (like address for example) of a certain set of punctuation marks. We are currently using a user-defined scalar function containing a set of...

View Article

Pass parameters to ssis package through agent job.

I have a SSIS package that need couple of parameters to be mapped. The JOB is called from a Agent JOB and the JOB is called from a SP. How can I pass parameters via JOB?

View Article

How to migrate logins from 2008 SQL server to 2012 SQl server

Hi,How to migrate all logins from  default SQL server2008(enterprise edition) to 2012 SQl server(enterprise edition)default

View Article


Is there a way to clone/duplicate a table row in SQL using an existing row...

I basically want to take a row of data (Primary Key=0), in a number of tables all with different schema, and call it the "default" and clone it each time as a starting point, simply giving it a new...

View Article

Need help with range selection

 I have a dog database that users will need to select (among other criteria) breeds by size. The problem I'm struggling with is how to select those breeds that weight range span sizes. Some dogs, e.g....

View Article

Delete multiple records

Hi All,I have below query ina stored procedure which deletes multiple records based on IDsDeclare @strProducts varchar(MAX) set @strProducts = 'SELECT pt.ID from Products pt INNER JOIN Price pr ON...

View Article


Query table field updates

I am working with a history table and can create a query to join an audit row to the prior row.  What I need to do is to come up with sql to compare all fields in the row and only return fields &...

View Article


join two PIVOT table

with NoOfOrder as ( SELECT Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec,Jan,Feb,Mar FROM ( select LEFT(datename(month,InvoiceDate),3) mon,InvoiceNo as InvoiceNo from tbl_InvoiceMain...

View Article

DATETIME2 Internal Storage Structure

I propose the following:DATETIME2 8 bytes (precision > 4) internal storage structureo 1st byte: precision like 7 o middle 4 bytes: number of time units (smallest 100ns) since midnighto last 3 bytes:...

View Article

Return only the ObjectName from DMVs...

Hi,When I ran the DMV below, I got details info but how can I can the top 20 SP name from the queries below. Please see the desired results below.Thank you so much in advance. -- Listing 4.6 The...

View Article

SQL Trigger does not wait for the Insert to complete

I am using After Insert Trigger on a specific Table.Now the Insert Statement to this table takes arround 60.000msec to complete.In Profiler I noticed that the Trigger is executed right after the Insert...

View Article


Stored Procedure for updating dynamic columns in a table

I have a table with a lot of columns around 30ishNow I want to create a stored procedure that will update a specific column to a new value.I the @columname and @newvalue to be the parameters, and an...

View Article

Order of precedence in where clause

Im getting an error on this statement:SELECT *FROM[My Table]WHEREISDATE([DATE OF BIRTH])= 1ANDCONVERT(DATETIME, [DATE OF BIRTH], 101)<'01/01/1899'Because its evaluating the second condition first...

View Article


type II dimension update scenario, loading back dated data.

Create these tables and stored proc to follow what I am saying.-- source table where we will put in some test data to load CREATE TABLE dbo.TestData ( BusinessCode VARCHAR(10) NOT NULL, Attr1...

View Article

Create Clustered index on a view

I have a view that takes forever to run. Can we create Clustered index on a view? Below is my code. Pl advise how we can create clustered index on this view?SELECT DisTINCT Field1, Field2, Field3,...

View Article


Need help in this query

 have table with column id   id   1   0  0   2  0   3I would like return   id      Rank  1         1  0          1  0          1  2         2  0         2  3          3

View Article

Help to Find out the correct answer to the following query

Hi, I have two tables named customer and salesorder. In the customer table i have 1000 customers,Of which 900 customers have orders in the salesorder table. i execute the following query to list all...

View Article

How to solve this error : The conversion of a nvarchar data type to a...

Hi,I have 13 million records in the table with nvarchar(254) column ( DocDate)  with values like '2010-02-19'.I have created another column (DocDate1 - datetime data type) and updating with DocDate...

View Article
Browsing all 23857 articles
Browse latest View live


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