T-SQL Questions


SQL or T-SQL
This question related to this thread: http://itknowledgeexchange.techtarget.com/itanswers/difference-between-sql-and-t-sqlmicrosoft-sql-server-2000/ So if I want to study SQL server, should I first study SQL and then T-SQL or just dive right in to T-SQL.

Answer Question   |  November 8, 2012  10:13 PM
SQL Server, T-SQL
asked by:
5 pts.

How do I subtract 3 days from current date only when current day = 2, so that I retrieve the previous Fridays date?
I am new to using T-SQL, so there is probably an easy way to accomplish this, but I can’t seem to get it right.  I want to retrieve the previous day’s date (requires a weekday) to use as a comparsioin to a date field in the table, format is YYYYMMDD.  When the current date is [...]

Answer Question   |  April 10, 2012  7:59 PM
T-SQL, T-SQL 2008 R2
asked by:
5 pts.

t-sql and AS400
I want to develop a TSQL query. First I need to determine if all the numbers in one of the fields are in numerical order and also find the missing holes in the number sequence. Secondly I need to sort by another field and by a particular criteria.  The words that I need to sort-by [...]

Answer Question   |  March 31, 2012  12:34 PM
AS/400 Query, SQL, SQL Query, T-SQL
asked by:
1,185 pts.

Ageing Report T-SQL
Im trying to write a query to retrive debtors ageing report in sql I have two tables [strong]1. Billing(billAmount,BillDate,AccountNo)[/strong] [strong]2.Payments(payAmount,payDate,AccountNo)[/strong] I need the output to show ageigng [strong]0-30, 31-60, 61-90, 91+[/strong] with the balances for each period The Billing table is pre-populated with the charges per month as per the amortization schedule when a client [...]

Answer Question   |  March 31, 2012  1:29 PM
MSSQL, SAP Aging Reports, SQL 2005, T-SQL
asked by:
45 pts.

SQL Server 2008 Insert Into vs Insert Statement Recompile
I have a stored procedure that executes a t-sql statement using sp_executesql. This t-sql code recompiles everytime it runs using “INSERT INTO” but when I use “INSERT” only it will not recompile. What is going on here? sample: create table #test (id int) Recompile: insert into #test select id from mytable Not Recompile: insert #test [...]

Answer Question   |  March 24, 2011  7:34 PM
SQL, SQL Server, SQL Server 2008, T-SQL
asked by:
585 pts.

How to concat SQL Server 2005 data with line feed
I am attempting to update a column in SQL Server 2005 by concatenating data from two other columns and include a line feed between the two and have the second line begin with a /. The data will be viewed through an MS Access 2003 database with a linked table using an ODBC connection. The [...]

Answer Question   |  February 2, 2011  10:46 PM
Access 2003, Concatenate, Line Feed, SQL 2005, SQL Server 2005, T-SQL
asked by:
45 pts.

iSeries SQL ISNULL Equivalent
What is the equivalent of the function ISNULL in t-sql in AS/400 iSeries Navigator SQL? or the equivalent of the NZ function in Access?

Answer Question   |  January 27, 2011  10:28 PM
AS/400, iSeries Access, iSeries Navigator, iSeries SQL, T-SQL
asked by:
60 pts.

T-SQL Programming Tutorials
I am looking for a website that is free and where I can learn to write better T-SQL views and stored procedures.  Also, would like to find some good books to learn more about managing a SQL 2005 database.

Answer Question   |  December 31, 2010  5:18 PM
SQL 2005 Database, SQL Server 2005, T-SQL
asked by:
10 pts.

T-SQL with Recursion – Display top ID on all levels below (To: Kent Milligan)
Hell Kent, I read through “V5R4 SQL Packs a Punch” http://www-03.ibm.com/systems/resources/systems_i_software_db2_pdf_rcte_olap.pdf    I would need the query in figure 20 and the result in figure 21 which do not show up in the article.  I have a query similar to the example (parts of an iSeries Power5 server) that shows all the levels correctly, however, [...]

Answer Question   |  November 29, 2010  1:36 PM
Recursion, SQL Query, T-SQL, V5R4
asked by:
30 pts.

Parameter in select statement
Hi, I need to pass a parameter into a stored procedure which values are dynamic always. Executing a variable which having the Select statement. Following query working fine. BEGIN DECLARE @strQuery NVARCHAR(MAX) DECLARE @CountryId INT DECLARE @CityId INT SET @CountryId = 2 SET @CityId = ‘ AND CityId IN (23,45,85,86)’ SELECT @strQuery= ‘SELECT VendorId From [...]

Answer Question   |  October 15, 2010  9:31 PM
SELECT statement, SQL Parameters, SQL statements, T-SQL
asked by:
40 pts.

How to add two timings in SQL Server 2008
DECLARE @TIME1 VARCHAR(10),@DURATION VARCHAR(10) SET @TIME1=’10:00′ SET @DURATION=’00:25′ SELECT CONVERT(TIME(0),@TIME1)+CONVERT(TIME(0),@DURATION) I need to add two timings …suppose if the @time1 is ’10:00′ and the duration is ’15′ mns then it should show 10:15 … Any help highly appreciatable…

Answer Question   |  May 18, 2012  7:59 AM
SQL Server, SQL Server 2008, SQL Server 2008 administration, T-SQL
asked by:
5 pts.

Calling stored procedure in a database to query data in another database
Hello, I am writing a stored procedure that will query data from another database, but the database name is variable. Do I have to use a dynamic query? We dont want to use dynamic queries because of performance loss. But is there a way to do it without a dynamic query? Example GetData ‘some_remote_db_name’; and [...]

Answer Question   |  February 14, 2012  3:20 PM
SQL 2005, SQL Query, SQL Select, SQL Server, SQL Server 2005, SQL Server 2005 administration, SQL Server stored procedures, T-SQL
asked by:
Ncs
5 pts.

How to split a column into SQL data..
I have table called  country having one column called complete_name (varchar(max)) which is as under   [table style="border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0"> [tbody] [tr] [td style="border: medium none #d4d0c8; padding: 0in 5.4pt; background-color: transparent; width: 6.15in;" valign="top" width="590"> [strong]complete_name[/strong] [/td] [/tr] [tr] [td style="border: medium none #d4d0c8; padding: 0in 5.4pt; background-color: transparent; width: 6.15in;" valign="top" [...]

Answer Question   |  June 24, 2010  4:09 PM
SQL Server 2005, SQL Server tables, T-SQL
asked by:
15 pts.

SQL indexes
hello, there are many indexes clustered an non clustered .so how can i see the result of each index, clustered and non clustered seperately through (T-SQL) pls guide me. RINO

Answer Question   |  June 8, 2010  12:21 PM
sql indexes, SQL Server, T-SQL
asked by:
135 pts.

SQL Server schema
Hi,    How can i get the user names assigned to the Schema through (T-SQL) Regards; Rino

Answer Question   |  May 25, 2010  10:51 AM
SQL Server, SQL Server schema, T-SQL
asked by:
135 pts.

Multithreading T_SQL
I have to pool data from 1000+ sites on different physical servers through a web service running on each server. What is the best way to do so using T-SQL so that the multiple threads/processes run in parallel

Answer Question   |  April 11, 2010  9:22 AM
SQL Multithreading, T-SQL, T/SQL
asked by:
5 pts.

Automate TSQL Query Output
I want to have a stored procedure run on a schedule that automatically creates a database output file as a result and saves it to a specific location on my network. Can someone please tell me how to do this?

Answer Question   |  June 1, 2010  1:14 PM
Automated SQL Query, SQL, T-SQL
asked by:
175 pts.

difference between t- and pl sql lang
in both t-sql and pl/sql we can use if/else condition and jump into other statements..then actually what makes the difference between t- and pl sql lang?

Answer Question   |  February 10, 2010  4:23 AM
PL/SQL, T-SQL
asked by:
5 pts.

passing data between two SQL Server databases
I am having an issue to passing data between two SQL Server databases.  I can not simply use Import/Export functions or Data Transfer Functions from SSIS because I was asked to transfer “20%” data with more than 15 criteria among 200 related tables.  Also we are not allowed to use the linked server,  which means I can not access [...]

Answer Question   |  January 12, 2010  6:29 PM
SQL 2005, SSIS, Stored Procedures, T-SQL
asked by:
25 pts.

Set identity to not for replication in T-SQL
Hi, Does anyone know the TSQL to change the identity column on a table in SQL Server 2000. And also the TSQL to change trigger to not for replication. Thanks

Answer Question   |  October 23, 2009  5:58 AM
ALTER, SQL Server 2000, T-SQL
asked by:
290 pts.