Skip to main content
The 2024 Developer Survey results are live! See the results
5 votes

Alter table - add a new column as the first column in the table - sql server

that is all good, but I need the new column to be the first in my table, is there a way to get this done? SELECT server_name, DRIVE, FREESPACE You shouldn't care what the ordinal number of a column ...
Sean Gallardy's user avatar
4 votes

create_date and modify_date for sys.objects in MSSQL shows same date

I assume you are actually talking about sys.objects view, and not sys.sysobjects. It seems like the modify_date is set to create_date until some other changes to table are made (which is pretty common ...
Yano_of_Queenscastle's user avatar
3 votes

Alter table - add a new column as the first column in the table - sql server

Agreed with Sean... But in the interest of answering the question for those who have a use case where column ordinal matters, one way to accomplish your goal is by selecting everything into a new ...
J.D.'s user avatar
  • 38.4k
2 votes
Accepted

error when re-applying the permissions script into the original database - sql server

You need to exclude internal tables using is_ms_shipped = 0. You also need to quote names correctly using QUOTENAME. You need to handle WITH GRANT OPTION correctly. You probably want to add AS ...
Charlieface's user avatar
  • 13.7k
2 votes

Alter table - add a new column as the first column in the table - sql server

I also agree with Sean, but if your actual script is what you have shown, then I would do it in this way. IF OBJECT_ID ('tempdb..#FREE_SPACE_DRIVES','u') IS NOT NULL BEGIN DROP TABLE #...
Jonathan Fite's user avatar
1 vote

Tsql help - doing a large update from CSV file to a table in ssms

You can use https://sqlgenerator.io to convert an excel/csv/json file into a CREATE TABLE and INSERT INTO TABLE SQL statements with the corresponding data. It's a free tool I created as I have to do ...
Ryan Waldorf's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible