This question already has answers here:
How can I get column names from a table in SQL Server?
(22 answers)
Closed 6 months ago.
I have a table name as 'tblOrder', having three columns. I would like to print the column names.
I want a script that should return a result as:
OrderId Name OrderTrackingNo
SELECT * FROM sys.columns WHERE object_id = OBJECT_ID('tblOrder')
Try this
Related
This question already has answers here:
IN vs OR in the SQL WHERE clause
(8 answers)
Closed 5 years ago.
I would like to know from below queries, which one would give better performance and how?
select * from TableA where (Name = 'ABC' or Name = 'DEF' or Name = 'GHI')
or
select * from TableA where Name in ('ABC','DEF','GHI')
Internally both IN and OR operators perform the same action. More importantly you need to see if you have proper index on the Name column.You can have a non-clustered index on the Name column and have one clustered index on this table.
This question already has an answer here:
Finding updated records in SSIS -- to hash or not to hash?
(1 answer)
Closed 5 years ago.
I've the following workflow in SSIS 14:
Each source have more than million records and I need to execute this workflow everydays at week.
My question is: How can I say to SSIS that I only want to extract only the records that not exists in Table Destination? Like a
INSERT INTO TABLEA
SELET * FROM TABLEB
EXCEPT SELECT * FROM TABLEA
Many thanks!
You can use the Lookup transformation to find out if something exists already.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Concatenate a selected column in a single query?
I know this is fairly simple in MySQL, but i don't know how to do it in SQLServer. I have a table containing two columns. UserID & TagID. I'd like to concatenate TagID into a comma separated string, where the result is grouped by UserID. How can i do that?
I would ythink something lik ethis might be what you are looking for :
SELECT ''+Table1.UserID+','+Table2.TagID+'' AS CombinedCSVColumn
, SUM(Table1.Value) AS Value
From dbo.Table1 as Table1
INNER JOIN db.Table2 as Table2
ON Table1.EmployeeID = Table2.EmployeeID
GROUP BY ''+Table1.UserID+','+Table2.TagID+''
That is if they come from two Tables. For one table is similar.
Regards
Mac
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to Get Last Created Entry's ID From Sql Database With Asp.Net
How to get last inserted id?
I am facing difficulty to get the last inserted field in
selct scope identity();
SELECT *
FROM Person
ORDER BY PersonID DESC
LIMIT 1
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Why (and how) to split column using master..spt_values?
I have seen something like:
Selet ... from master..spt_values where type='P'
What does this mean?
That is the syntax for specifying a databasename, schema, and table name. You can use this syntax to specify a database different from the database you are currently connected to. In your example, master is the database name, the schema name is unspecified (so it becomes the default dbo schema) and spt_values is the table name.
For clarity, the above could also be: Select ... from master.dbo.spt_values