Click here to Skip to main content
Page 1 of 3
Page Size: 10 · 25 · 50


Tag filtered by:  T-SQL [x]
Answer 9 May 2013   license: CPOL
Try adding parameters like this: SqlParameter dataParameter = new SqlParameter(); dataParameter.Value = txtEmpNo.Text.Trim(); dataParameter.ParameterName = "@EmpNo"; SqlParameter dataParameter2 = new SqlParameter(); ...
Question 9 May 2013   license: CPOL
I have created the following Stored Procedure in an SQL Server Express Instance. I am using Visual Studio 2010 Professional and SQl Server 2008 Express edition.USE [LeaveMgt]GO/****** Object: StoredProcedure [dbo].[LeaveApply] Script Date: 05/10/2013 02:06:31 ******/SET...
Technical Blog 9 May 2013   license: CPOL
Backing up all databases using T-SQL
Question 7 May 2013   license: CPOL
Dear all, I require your opinion on what approach is good and/or practical for the following scenario.There is a web application which queries data from SQL server.For example: Users report to a manager1. The process by clicking a button is finding who reports to me (manager)2....
Answer 6 May 2013   license: CPOL
Hi...Use this Query with Decode functionSELECT P.*FROM PTABLE P,MTABLE M,NTABLE RWHERE P.MATERIALID = M.MATERIALID AND P.MATERIALID = N.MATERIALID AND P.MATERIAL = DEOCDE(P.MATERIAL,NULL,P.MATERIAL,N.MATERIAL)If you have any clarification,please don't hesitate to contact...
Answer 5 May 2013   license: CPOL
Try This,SELECT P.*FROM PTABLE PLEFT JOIN MTABLE M ON P.MATERIALID = M.MATERIALIDLEFT JOIN NTABLE R ON P.MATERIALID = N.MATERIALIDWHERE M.MATERIAL = CASE WHEN P.MATERIAL IS NOT NULL THEN N.MATERIAL ELSE P.MATERIAL ENDHappy Coding!:)
Question 5 May 2013   license: CPOL
Hello,I am trying to apply IF/ELSE or CASE/WHEN to my select statement but I am not successful. Can someone help me how to write this?My query is:SELECT P.*FROM PTABLE P, MTABLE M, NTABLE NWHERE CASE WHEN P.MATERIAL IS NOT NULL THEN M.MATERIAL = N.MATERIAL ...
Answer 17 Apr 2013   license: CPOL
Try it:SELECT SUM(P.ITEMAMOUNT) AS AMOUNT, P.COMPANYID AS COMPANY, SUBSTR(P.ACCOUNTID, 1,5) AS ACCOUNTFROM PRODUCTS P INNER JOIN ACCOUNTS A ON P.COMPANY = A.COMPANY AND P.ACCOUNTID = A.ACCOUNTIDWHERE P.ACCOUNTID LIKE '1%'GROUP BY P.COMPANY, SUBSTR(P.ACCOUNTID, 1,5)ORDER BY P.COMPANY,...
Question 17 Apr 2013   license: CPOL
Hello all,I need a slight change in my query to get me different result set. I have written the following query:SELECT SUM(P.ITEMAMOUNT) AS AMOUNT, P.COMPANYID AS COMPANY, P.ACCOUNTID AS ACCOUNT, A.ACCOUNTDESCFROM PRODUCTS PJOIN ACCOUNTS A ON P.COMPANY = A.COMPANY AND P.ACCOUNTID =...
Answer 17 Apr 2013   license: CPOL
declare @AssetDescr VARCHAR(30)set @AssetDescr= 'This has quotes at "6".'select @AssetDescrSELECT REPLACE(@AssetDescr, '"','''')
Question 17 Apr 2013   license: CPOL
how to replace double quotes by single quotes in sql server
Answer 22 Mar 2013   license: CPOL
Maybe something like adding another column to the temp tableNot tested.DECLARE @mid INTSELECT @mid = max(siteid) FROM tblTEMPALTER TABLE tblTEMPADD inc INT (@mid, 1) NOT NULL;
Answer 22 Mar 2013   license: CPOL
Have a look at this example:CREATE TABLE #tblACC (siteid INT, p_id INT, descr VARCHAR(30), code INT)DECLARE @curcount INTDECLARE @code INTSET @curcount = 0SET @code = 10WHILE(@curcount
Question 22 Mar 2013   license: CPOL
Hello all,I have a retrieved some data from a table and inserted them into a temporary table lets say tblTemp. The output of this table is:siteid p_id desc code 11 1 test 1 2211 1 test 2 2211 1 test 3 2211 1 test 4 22I...
Answer 3 Mar 2013   license: CPOL
Hello ,Create one stored procedure as mentioned below CREATE PROCEDURE spSavePurchase_Order_Products( @OrderInfo AS XML)AS BEGINDECLARE @tblOrderInfo AS TABLE(Product NVARCHAR(MAX),Qty INT , Amount INT)--DECLARE @tblOrderInfo AS TABLE(ProductId NVARCHAR(MAX),Qty INT ,...
Answer 3 Mar 2013   license: CPOL
Hi,For your solution you need to study Using Transactions in ADO.NET[^] and read about SqlTransaction Class[^]. After study this you are able to integrate such given example's code into your system. Please review below...
Answer 3 Mar 2013   license: CPOL
Hi swissivan,(I Assume you're using MS SQL Server for db)You can have a SQLCommand object, A connection to db and list of all queries to be executed whether it is call a procedure or it's a text command. Add all the queries to the list, create a SQLTransaction object for you SQLConnection...
Question 3 Mar 2013   license: CPOL
I got two Tables 'Purchase Order' abd 'Purchase Order Products'.I am using .NET c# program to call store procedure.I would like to generate id and insert record for 'Purchase Order' first. Then insert records for 'Purchase Order Products' since it includes the ids generated.If just...
Answer 22 Feb 2013   license: CPOL
Hi Friend,You need to make Audit of all New Procedures and Track the Procedure Changes with Procedure Text right. Here clearly explained how to do Audit in care of any procedure changes in DB. You will go for Database Trigger and get the details from Trigger and Store in a table in...
Question 22 Feb 2013   license: CPOL
Hello FriendsI need to create a trigger on Sys.Procedures.I know the syntax of creating trigger but I don't know how to access the inserted row fields.I mean, my trigger statement depends on the fields of the inserted row in the...
Question 19 Feb 2013   license: CPOL
Hi I am passing this xml content as parameter to get a response: PAYMENT gemeya 910573404 msisdn ...
Question 17 Feb 2013   license: CPOL
this question is deletedthis question is deletedthis question is deleted
Answer 17 Feb 2013   license: CPOL
Don't quite understand your talk of loops etc. but an observation:Your code is summarised asif duration
Answer 14 Feb 2013   license: CPOL
Looks like a homework assignment to me.1) Identify the injection threat (there is one)2) Use existing code to figure out how to remove the threat. (examine the other parameters)3) The code only looks like it is preventing all inserts because of the user response "Record already exists"...
Answer 13 Feb 2013   license: CPOL
cmd = New SqlCommand("Delete from StudentDetails.Registration where StudentId='" & txtStudentId.Text & "'", cn) cmd.ExecuteNonQuery() cmd = New SqlCommand("Delete from StudentDetails.Students where StudentId='" & txtStudentId.Text & "'",...
Answer 12 Feb 2013   license: CPOL
On a blog you provided, sort is done by reads intensity. Actually this is correct, as most likely such queries execute very long.If you are targeting queries by absolute time used to get the result, you might use slightly modified query from your blog post: order by qs.last_execution_time...
Question 12 Feb 2013   license: CPOL
Hi,I have currently working on performance enhancement project,and I am finding time consuming queries from sys teble,sys.dm_exec_query_stats,ref:http://blog.sqlauthority.com/2010/05/14/sql-server-find-most-expensive-queries-using-dmv/[^]when I run this query on production...
Answer 11 Feb 2013   license: CPOL
If your UDF gives you back a table..Select xxx from Properties AS P join theUDFTable AS U on P.Area_Id = U.AreaID
Question 11 Feb 2013   license: CPOL
I am trying to construct a sort of "Property Search" Query for my site.Where I am so far: I have a multi select dropdownlist on my site that contains "Neighborhoods" within a city. I am passing the selected IDs of that dropdown to a stored proc via a comma delimited list (varchar). I am...
Answer 7 Feb 2013   license: CPOL
Two changes:qry = "Update ProgramDetails.Subjects set SubjectCode=@SubjectCode,SubjectName=@SubjectName,SubjectType=@SubjectType,UserID=@UserID,Password=@Password where IDNumber=@IDNumber"and then insert before cmd.ExecuteNonQuery()cmd.Parameters.Add(New SqlParameter("@IDNumber",...
Answer 7 Feb 2013   license: CPOL
You're doing a fine job using parameters, so why this:IDNumber='" & txtIDNumber.Text & "'"Btw: You are comparing IDNumber, which I assume is a number, with a text string ...Best regardsEspen Harlinn
Question 7 Feb 2013   license: CPOL
In the following code the command executes but update doesn't take place. The main issue is the primary which is IDNumber is set to IsIdentity in the SQL Server database. I'd be thankful if someone could help me out.If rbnCore.Checked = True Then subject = "Core" ...
Answer 29 Jan 2013   license: CPOL
The conditions basically look just fine. With a quick look possible problems may be:- you haven't used table aliases in front of field names. In order to avoid ambiquity, always define the table alias where the field is taken from- if either of the columns may contain a NULL value, you have...
Question 29 Jan 2013   license: CPOL
So my other Where parameters work fine, it's the line of code in Bold/Underlined that I can't figure out. That line of code I'm basically trying to say, "If ResponseID is not equal to 62 and QuestionID is not equal to 1888 then proceed". Anyone want to take a shot at how I can use those 2...
Answer 29 Jan 2013   license: CPOL
1. Do not remove spaces from the subname variable during the Form Load event.subname = Module1.sname2. String.Format("%{0}%", "") creates a string parameter that contains %%. Used with the LIKE operator, it will match everything in the database. Please change that line of code to...
Question 29 Jan 2013   license: CPOL
In the following code all the subject codes are read by SQLDataReader rd. How do I make the DataReader read the subject code of only the selected subject regardless of whether the subject name contain white space or not such as Biology, English Language, Principles of Cost Accounting, etc? ...
Answer 28 Jan 2013   license: CPOL
RTRIM[^] And/Or LTRIM[^] in your SQL statement.Alternatively you could use String.Trim[^]
Answer 23 Jan 2013   license: CPOL
Solved it myself.For some reason, I haven't found, this scenario (Trigger on one DB inserts rows on table on another DB that fires a CLR trigger) doesn't work at all.Turned to a Service Broker messaging solution and it's working in perfection now.
Answer 20 Jan 2013   license: CPOL
Again[^]. Why are you wondering? You define two CTE-s on to of the same records sets, and one is recursive. Try to run a profiler to see what locks are occurring. If you know better query plan than the optimizer, add a hint[^] to it.
Question 20 Jan 2013   license: CPOL
Hi,I am trying to create sp for grid paging and I am using CTE,my CTE query is ,with cte as(select .......)select * from ctethis query takes 250ms to execute,but when I am adding the count() for counting the cte query record it is taking about 700ms to...
Answer 12 Jan 2013   license: CPOL
The best way to achieve that is to create stored procedure[^], like this one:USE YourDatabase;GOCREATE PROCEDURE GetLatestDailyChange @client VARCHAR(10), @db VARCHAR(30), @class VARCHAR(30), @function (30)AS SELECT CHANGEDBY, CODE, CHANGEDAT ...
Answer 10 Jan 2013   license: CPOL
SELECT C.ChangedBy, C.Code, C.ChangeDateFROM dbo.logs c WITH(NOLOCK)WHERE C.ChangeDate IN(SELECT MAX(C.ChangeDate) FROM dbo.logs c WITH(NOLOCK) WHERE CONVERT(DATE, , C.ChangeDate) = CONVERT(DATE, , C.ChangeDate) GROUP CONVERT(DATE, ,...
Answer 10 Jan 2013   license: CPOL
hey try below T-SQL Code : CREATE TABLE #TEMP( ID INT, CHANGEDATE DATETIME)INSERT INTO #TEMP VALUES(1,GETDATE())INSERT INTO #TEMP VALUES(2,'2013-01-09 10:04:00')INSERT INTO #TEMP VALUES(4,GETDATE())INSERT INTO #TEMP VALUES(3,'2013-01-09 08:11:00')SELECT...
Question 10 Jan 2013   license: CPOL
Hello all,With the following query I am trying to pull some data from a table:SELECT c.CHANGEDBY, c.CODE, c.CHANGEDATFROM logs cWHERE c.CLIENT='00' AND c.DB='DBNAME' AND c.CLASS='CLASSNAME' AND c.FUNCTION='FUNCNAME'The table consists of the following columnsID(int), DB(varchar),...
Question 4 Jan 2013   license: CPOL
Hi ,i developed some reports and deployed , all reports are working fine .now my requirement is changed that is i have to change my server url from http to httpsex:actualonehttp://localhost:80/reportservermy requiremnt is https://localhost:80/reportserverits urgent...
Answer 2 Jan 2013   license: CPOL
The scope of the temp table is limited to the dynamic query when its defined within the dynamic query. Alternate options are - you can use Global temporary table[^] or create the temp table outside your dynamic query. Take a look at the below link for more...
Question 2 Jan 2013   license: CPOL
Hi Recently i tried to create one temp table before dynamic sql and i compiled the SP.when i tried to execute the SP it is giving the error like my temp table doen't existex:PROCEDURE [dbo].[Proc_test]asbeginDECLARE @sqlstring NVARCHAR(4000)select * into #test from xtableSET...
Answer 10 Dec 2012   license: CPOL
Figured out why the truncation is occuring. Here posting the results as the answer to the problem; my use of [nvarchar] to contain data of type [varbinary].As an example:SELECT CAST('0x50004F0049004E00' As binary) --...
Question 7 Dec 2012   license: CPOL
The problem is I can't find ANY method to provide, SELECT query or PRINT or otherwise, a string of characters as a plain string of characters.USE[master]GOCREATE SCHEMA [DCST]CREATE TABLE [DCST].[geoGeo]( [idx] [int] IDENTITY(1,1) NOT NULL, [GeogCol1] [geometry]...
Question 26 Nov 2012   license: CPOL
HiI've been Googling all day for a help on this problem and couldn't find any answer.It concerns a timeout error in SQL Server 2008 R2 when a T-SQL Trigger in one Database fires a CLR Trigger on another Database.This is my scenario:First DB (PORTAL_MENSAGENS) has a trigger that fires...

Page 1 of 3
1 2 3


Advertise | Privacy | Mobile
Web02 | 2.6.130513.1 | Last Updated 13 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid