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

Image may be NSFW.
Clik here to view.

Coalesce in a SQL View?

I have a table as shown below:I need to write a sql view that will show 1 row for the ReqNbr and then a column for the related service calls.  For example the result set should look something like...

View Article


Rename tables and Build Indexes Dynamically in SQL

I have a need for a stored procedure , where user can pass the tablename,schemaname and indexname as input variables.Then the stored procedure should accept those as input variables and do the foll...

View Article


Issue in replacing Cursor

I have a Cursor to be replaced build based on if exists condition , Cursor needs to be replaced because of performance issues.I am missing logic behind the If exists condition, So if any alternative to...

View Article

JOIN

UPDATE ARH SET [OPEN] = 'TRUE', CLOSEDATE = NULL, PAID = ARH.PAID - NEW.AMOUNT FROM (SELECT INVOICE, AMOUNT FROM CREDITMEMO WHERE CINVOICE = 113202)NEW JOIN ARH ON ARH.INVOICE= NEW.INVOICEThis query...

View Article

Need help to solve update querry for multiple records.

Could any of you please provide update querry for the following scenario.Requiremnt:1. Update the UNIQUE_ID of record ( same Identifier and Identifier_code where END_Date is not null) with the...

View Article


join tables based on condition

declare @id int select *  from tablea inner join  case when @id = 1 then tableb on a.id = b.id                             when @id = 2 then tablec on a.id = c.id                             else 'dont...

View Article

BCP is not working in when i am executing using xp_cmdshell

Declare @cmd varchar(300) Set @cmd= 'bcp "SELECT definition + char(13) + ''GO'' FROM test.sys.sql_modules s INNER JOIN test.sys.procedures p ON [s].[object_id] = [p].[object_id]  WHERE p.name LIKE...

View Article

Passing Declared and Set parameter to another query in a Stroed Procedure

I Have  th efollowing stored proceedure that is suppose to create a key val:ALTERPROCEDURE [dbo].[GenerateNCRId]@Division varchar(3),@DeptCode varchar(3),@NCRDetailsID varchar(50),@NCRCode...

View Article


Conversion Failed when converting varchar value to Int

Hi All, I have this below query SELECT  Distinct card_transaction_log.Location,COUNT(card_id),SUM(Amount)  FROM [cwvaluecard].[dbo].[card_transaction_log]  left outer join...

View Article


find same day shipments

we have customers with multiple sub accounts and I'd need to see if these sub accounts had same day shipments (to consolidate these shipments into 1 and save on freight charges).I have a Shipment table...

View Article

Programtically copy structure and indexes/constraints from one SQL Server to...

I have the need to copy the structure and indexes from one SQL To another SQL Server. THere are about 200+  tables. If I do select top 0 * into... copies the structure but not indexes.I need something...

View Article

How to see Execution details of stored procedure using DMV

Hi, I would like to see execution details of stored procedure  but the following not showing. Could you please suggest. I can see them using profiler/trace/extended events but is there way to see using...

View Article

Pivot Table

I have a pivot table in my select statement, it works fine, however, I need to pivot the data again?So after I FIRST Pivot the Data I get a list of values in From a  Name column, now I want to take...

View Article


convert rows ro collumns

I have this data, where number of rows can be different:select '' col1 union  allselect 'asd'   union  allselect 'gfrf2'   union  allselect '2_44ff'   union  allselect 'ae6754'   union  allselect 'fff'...

View Article

Generating Records based on frequency

HiWe get requests by selecting a certain frequency. Based on the frequency selected by the user we generate records  for that request until an expiration date. We currently support monthly and...

View Article


Loop through all Logins to find Locked logins?

What T-SQL code could I use that would iterate through all Logins on an instance and identify SQL Server Authenticated logins that are locked? I know how to determine if a given Login is locked,...

View Article

Cast Command with Case erroring out

I am trying to search a text field for the words 'Ship complete' when I find this information I want it to put 'SC' into the output, if it doesn't find these words I want the output field to be blank....

View Article


Add Table Valued Parameter to a stored procedure

I have a stored procedure that voids an invoice and puts the items back into inventory and makes available the payment that was used to apply to this invoice... I would like to be able to do all this...

View Article

Need a PIVOT-like solution

I have a stored procedure based on a primary table that has multiple rows for different dates within a year.  I want the result set to display all dates as separate columns. Normally there are no more...

View Article

SEARCH Employee table based on EXACT Date of Birth or PARTIAL Date of Birth

Hi all,I have a scenario where I would like to retrieve a record from EMPLOYEE table based on our end users enter the EXACT Date of Birth or just a partial Date of Birth.I am able to retrieve a record...

View Article
Browsing all 23857 articles
Browse latest View live


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