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

Loop In sql

Hello all I want to make a loop in sql without use cursor is it possible?i want to write a query like this .@test=select name from table1if @test<>"Muzahid"beginend some queryelse some queryin...

View Article


Insert Records that exist in one table that are not in another

I have 2 tables. One is a master table and the other is a temporary table that is used for importing data. There will be times when the import file will contain a part # that we do not have in the...

View Article


Linq: count(distinct) conversion

hi folksI'm having trouble converting the following (functional) SQL statement into LinqSELECT     TOP (100) PERCENT UsrComp, CurrentDate, COUNT(DISTINCT [User]) AS UniqueUsersFROM...

View Article

sql server 2012 Logon trigger not working for certain logins

Hello. I created a login trigger to insert data for each login in a table, and it works for all logins except one that is format domain\login and the login ends with the dollar sign(actual name is...

View Article

Identify the first 2 records in a group and annotate

First off, I want to thank everyone for all the support. I really do appreciate all the assistance. What I am trying to do now is identify the first 2 records in a group and annotate them like...

View Article


If the value doesn't exist in a table, query another table. How to do that ?

I am using SQL Server 2012. I have 2 tables, tblA and tblB that have the same columns with different data. Both have columns Symbol and Name. I also have another table, tblC that has a column Symbol.In...

View Article

Parse comma separated value and map with other table to get Name and change...

Hi,I have one existing view(with around 15 fields), in which I have to add few more fields from table called PI.Now these fields have values like (55C4444F-D83B-4F96-A011-367A3755BA6C ,...

View Article

Image may be NSFW.
Clik here to view.

Select and SQL sorting

LedgerIDName    Type ParentID ----------------------------------------------------------- 1001AA CLASS1 1002BB A/C1001 1003CC A/C1001 1004EE CLASS1008 1005DD A/C1004 1006FF A/C1004 1007GG A/C1001...

View Article


How to convert Date in varchar(50) format MM/DD/YYYY HH:MM into YYYY-MM-DD...

Hi,I am getting the error "The conversion of a varchar data type to a datetime data type resulted in an out-of-range value." when converting date in format Date in varchar(50) format MM/DD/YYYY HH:MM...

View Article


Need help with query optimization

I have one simple query to optimize but somehow after creating couple of index this query is still having more logical reads and time.DECLARE @CURRENT smalldatetime set @current = '6/30/2013' select...

View Article

Example for GetDescendant()

Can anyone give Exmaple for select Query by having  GetDescendant() in where condition.

View Article

datatype conversion error.

hi Friends,i have create one function and its function having parameter number which is in decimal.but my datatype of this column in table is NVARCHAR.now m execute this function like..  RETURN...

View Article

Disable Foreign Key Constraints

Destination DB is sql2005. When export data to this db from various locations through a syncing app,  Foreign Key Constraints error occurs. This will be solved through disable enable these constraints...

View Article


sql server 2008

How can i do to  export from one sql server 2008 to another sql server 2008.

View Article

Matrix output

HI,I have data something like this:                     IDTypeCode      value 1termterm  1 2term term 2 3Channel CHNRetail 4Channel CHNRetail90 5Drug DRGBrand 6Drug DRGGeneric Output: i need ALL...

View Article


Key on a table

hiI need to design a table for holding employees. Each employee should have one manager and he is also an employee..Create table EmpTable ( Emp_Id int not null, ename varchar(100), mgr_id int unique  ,...

View Article

how to display data from 2 tables, like below

Hi, I've 2 tables like belowTable1 FirstName           LastName            RoleJohn                     due                        ManagerKris                       wen                       CEO...

View Article


Why does my query not yield the expected result?

Hi everybody,I'm a bit lost here on my SQL 2008.I have two tables: tbl_transaction and tbl_devicehistory (1:n). The relation is described in the first query.I want to find all entries in...

View Article

Splitting columns using xml path

Please see my script below,This is one of the msdn user request but as he is newbie unable to put ddl and dmls.. but all he wants is doing pivot on values.. but I'm trying the same using dynamic pivot...

View Article

Including a SUM within a grouped UNION query

Hi -- I have inherited a SSRS (Project Server Resource) report comprising two queries with a UNION. There is a requirement to add ONE extra column (MonthlyTotal) which SUMS the total WORKDEMANDFTE for...

View Article
Browsing all 23857 articles
Browse latest View live


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