T-Sql
i have a database having 2 tables emp and dept the emp table has coulmns emp_name , DOB, dept_id the dept table has dept_name, dept_id i want to get the youngest employee with dept_name if anyone can...
View ArticleComparing two columns with different data types
HiI am trying to compare two columns in different databases (using linked server connection). Both columns are phone numbers but one of the columns is xml data. When I run the following query:SELECT...
View ArticleMulti Value Parameter in a Query.
Can someone guide me thru on how to make this happen, I have a report to generate which will let a user select Customer,SalesRep,Location & Product. I need to write a query which will let the user...
View ArticleInsert max(id) + 1
Hi I am trying to insert data from table A to table B. Table A doesn't have id. How to insert MAx(id) +1 for each insert row?Insert into table B(max(id) + 1,EIN,YEAR)select distinct EIN, YEAR from...
View ArticleHOW TO INSERT VALUES INTO A IDENTITY COLUMN
HI All,i have a only one ID column in a tableDDL:CREATE TABLE TEST_IDENT ( ID INT IDENTITY )Now i want to insert 1000 rows at a time:bala krishna
View ArticleHow To: Add an IDENTITY column to This View?
Hi,How to add an identity column to this view:CREATE VIEW [dbo].[MainStatistics] AS SELECT (SELECT COUNT(*) AS EXPR1 FROM dbo.Courses) AS CoursestCount, (SELECT COUNT(*) AS EXPR1 FROM dbo.Certificates)...
View ArticleDeleted a database in Access from TSQL?
Hello I have a table in Access that I'm trying to delete then update in TSQL. I know how to do it in Access, but how would I go about doing it from TSQL? In Access i run this:DELETE table.* FROM...
View ArticleAverage column
Good Morning,I am wondering how I can add a column to this SQL script that will calculate the AVG(PROC_TIME).If the PROC_NUMBER IS >= 10 Then the AVG should be grouped on MD_CODE,...
View ArticleMerge statement internals
Hi experts, I would like to know how merge statements works , internaly. Like how its use tempdb what is the step to excute it . The main reason of this question is , I faced slow runing merge...
View ArticleAre you a technology guru? Show us your solutions and become the T-SQL Guru...
TechNet Wiki is looking for and celebrating the best of the best!Is that you? Do you consider yourself an expert, or authority on T-SQL?Show us your forum solutions and become MICROSOFT TECHNOLOGY GURU...
View ArticleJoin query question
This is an example. I have this below query. Is the last two joins valid ?"and d.org_key = b.system_id and d.category_key = c.category_key". Can I cross refer join.Select * fromAjoin Bon a.rep_id =...
View ArticleNeed a good place to learn general error handling
Basically I am self taught using full examples to break things apart and see how they work. I am writing a new web application in C# and for the first time need to logically handle transactions. After...
View ArticlePassing String Text From MS Access to SQL Server - 128 Character Limit
My Question is: How can I pass Text Strings form Access to SQL server when the string is greater that 128 characters in length?I have Large string text stored in a MEMO table in MS ACCESS (being used...
View Articlehow to declare a variable similar to table column type?
hi all,currently, i declare variable in stored procedure similar to db table column. is it a way to declare it like below:x_order_noso.order_no%type;i need to do it so that i dont need to change the...
View ArticleYtd, Weekly, Monthly and Quarterly Data
Hi, I have a requirements to pullout data and show the result for Ytd, Weekly, Monthly and Quaterly. this is a combination of 4 requirements with different table use.number 1 query, im using sample...
View ArticleQUOTED_IDENTIFIER
How can I identify whether the QUOTED_IDENTIFIER is ON/OFF?Best Luck, Shenoy
View Articlebelow query i need to write case statment (how to write case stament)
below reqirment is in CASE EXP AND UPDATE STAMENT:-i have two table's EMPUDF_E and CSTMSELELEM_E and key column are EMPUDF_E.CUSTOMSELECTIONELEMENT_I=CSTMSELELEM_E.NUMBER_Iget CSTMSELELEM_E.NAME_N in...
View ArticleSuggestion for good T-SQL code formatting rules and tools
Dear collegues, I am struggeling with finding a good standard for our T-SQL code layout and indentation. Also, I would like to introduce a tool at our company that does the code layout for you. I have...
View ArticleDo I need to INCLUDE the primary key in an index or not?
Dear collegues,The INCLUDE syntax in indexes is new to me. If I understand the online help correctly, every index will automatically include the clustered index. So if I have a table with a foreign key...
View Article