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

Image may be NSFW.
Clik here to view.

Update a Temp table based on a condition

DECLARE @CokeTypes TABLE (CampaignID INT, CokeTypeName NVARCHAR(max), StartDate DATETIME) INSERT INTO @CokeTypes SELECT DISTINCT cc2.CampaignID, (SELECT cc1.CokeTypeName + '- (' + CAST (cc1.Percentage...

View Article


Clarification on the limitation of sequence generator in T-SQL

Hi, I found this limitation of sequence numbers for T-SQL:"If there are multiple instances of the NEXT VALUE FOR function specifying the same sequence generator within a single Transact-SQL statement,...

View Article


xml data to sql table row using ssis

Hi ,im trying to dump the entire data of an XML file to my sql tablemy table is XML destination(tblxmldestination)xmlColumn varchar(max)how can i achieve this which transformations i can make use any...

View Article

Extract min timestamp from string

Hello all,I am trying to query the minimum datetime from a column that is stored as nvarchar(max). There a a few tricky things with this query (at least for me)- There is more than just the date being...

View Article

Image may be NSFW.
Clik here to view.

SQL Query with a little bit more complicated WHERE clause performance issue

Hello, I have some performance issue in this case:Very simplified query:SELECT COUNT(*) FROM Items WHERE ConditionA OR ConditionB OR ConditionC OR ...Simply I have to determine how many Items the user...

View Article


Storing a Timestamp value

I need to read the last timestamp value (MAX(TimeStampValue)) from a table, store it in a separate table (TableMaxTimeStamp) and perform a comparison against another table and load delta records. I'm...

View Article

Evaluating Previous Row Value to Current Row Value and Performing Action

I need to perform a series of evaluations and then do an update on fields if they are true. The evaluation is performed on a single table against the current row and the previous row. I'll try to show...

View Article

Adding Deadlock Retry Logic to the Stored Procedure

Could you please any one explain with exampleThanks

View Article


nvarchar to numeric conversion error issue with derived tables

I have an issue with a varchar column while using derived tables but it works fine with temp tables.createtable#A(idint,grp_idint);insertinto#A...

View Article


SQL server Query help

I have four table like below: CREATE TABLE Party ( PartyID int identity(1,1)not null, PartyRegisteredDate datetime, MemberNo varchar(16), SubsNo varchar(9), PerNo varchar(2) ) CREATE TABLE Contract (...

View Article

Help need in Avoiding Loop

Hi,My table and data:Create table Sample(Empid int primary key identity(1,1),EmpName varchar(50),Empsalary money,EmpDesignation varchar(30)); insert into Sample values('Jhon',8000,'Manager'),...

View Article

Order of records - finding preceding and next records

I have looked around a few forums for a similar question but I'm not really even sure what to search for!I have a table with some events, client names, timestamps for the event, and a category.  There...

View Article

Image may be NSFW.
Clik here to view.

Sql

I have a database that looks like this:I need to be able to get all the columns of one mangroup based on a search. The user will type in [type2] FPR = [disc] 2.50 and [type2] low = [disc] 1.00 and I...

View Article


How to union results in Powershell?

Hi!I am running two separate Invoke SQLcmd -Querys from powershellBoth of them work individually, but when I put them together only the results of the first query appear. Is there a way to do it so...

View Article

T-SQL Equivalent For Group_Concat() Function

Hello, I am looking for a way to do the MSSQL T-SQL equivalent of the MySQL aggregate function: group_concat(). We are running SQL 2005 Express. Is there a pure T-SQL way to do this, or if not, a way...

View Article


Image may be NSFW.
Clik here to view.

How to Loop through an inline query in SQL Server

DECLARE @Quantity FLOAT ,@Destination Nvarchar(100),@Source NVarchar(100),@RawMaterialConfigID INT,@CreatedDate DateTime DECLARE @QtyRcvd TABLE (Quantity FLOAT,CreatedDate DateTime) DECLARE @CokeSilo1...

View Article

Define constraint of 'a','b' or 'c' within column

Hi,What is the best and easiest way of defining a check constraint within a column within a table so only values 'a','b' or 'c' and be updated within that column.Kind Regards,Kieran.Kieran Patrick Wood...

View Article


export table contents to csv

Hi there,Straight to the point I have the following code in a stored procedure: DECLARE @FilePath VARCHAR(500) DECLARE @SQL VARCHAR(500) SET @SQL='SELECT * FROM blah blah;' SET...

View Article

CLR functions

Hi,Please I need a script that create all CLR functions (with its assemblies) for a specific Database (to move these CLRs to another database )  .Thank you.

View Article

How to find out who made inserts/updates/deletes made to a SQL Table

I want to know WHO MAKES INSERTS/UPDATES/DELETES TO a particular SQL Table. Bascially I want to AUDIT ANY Edites made to a SQL 2008 TABLE. I need info such as WHO AMDE THE Updates i.e. the user...

View Article
Browsing all 23857 articles
Browse latest View live


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