SQL Server 2012 using codes instead of design (TSQL) - sql

I am using SQL Server Management Studio 2012 and I want to create tables using SQL codes(TSQL) instead of designing the table, I saw tutorial on how to do this but when I try to open the file of the table it gives me this message:

I solve it, its very simple all I needed to do is right click the file it choose select top 200 and it will open tsql.

Related

Error when trying to show tables content from the staging server(Azure) via SSMS

I am connected to a remote Microsoft Azure server via SQL Server Management Studio. The problem I am facing is that I am not getting an option to "Select Top 1000 rows" of a table (screenshot attached). What I am doing wrong? I am using SSMS2012. Regards.
You are not wrong.
I tested using SSMS 2012 and have the same problem with you.
But, When i use SSMS 2017, i can get the option of "Select Top 1000 rows".
So we just need to update our SSMS to the latest version.
We can download the latest version of SSMS at: Download SQL Server Management Studio (SSMS)
In addition, we can also execute T-SQL directly: select top (1000) * from [TableName]

Copying an SQL table from one Server to another on SQL Server 2000 / 2005

I’m trying to copy a SQL Server table, schema and data, from Server A to Server B. The SQL Server table is just a reference table which hasn't been populated for some reason on Server B. Can anyone advise how the entire table could be copied across please? On SQL Server 2000/2005.
So far we've tried a long-winded approach by copying the .mdf and .ldf files from Server A to Server B with a plan to then copy the table across into the Server B database but we are having some difficulty re-attaching the database to Server B.
Please can anyone help?
Kind Regards
James
Using SQL Server Management Studio (SSMS):
In Object Explorer right click on source database name, Tasks.. -> Generate Scripts.. - opens Generate and Publish Scripts dialog. Click Next to choose objects, choose "Select specific DB objects", expand Tables, choose your table. Next, setup script destination, for example New query window and (important step!!) - click Advanced, and set "Types of data to script"="Schema and data" and "Script USE DATABASE"=False, OK, Next, Next, .. wait .. Finish. Now you have got complete SQL script to reproduce this table with data. Connect to destination DB and run it.
Tested with SSMS 2014, but as I recall this feature should be available starting from SSMS 2005.
you can use the import/export data wizard in management studio, the wizard will create for you a new table in the server B with the same structure of the table in the server A. before using it you need to have at least one database in sever B.
This confirms why this is one of favourite forums.
Both these methods work beautifully :
Generate Scripts (when altering Types of data to script"="Schema and
data")
Export and Import
Interestingly Generate Scripts works with SQL Express perfectly but the Export method does not save unless you have at least SQL Server Standard Edition.
Thanks so much everyone
Cheers
James
Try this:
SELECT * INTO destination FROM source
But, it will not copy the indexes and key information or you can also try import/export data task from SSMS.

T-SQL Script to copy data from one server to another?

Is it possible to copy data from one server to another using a T-SQL script? We have a code promotion process that makes using the import wizard less than optimal for our team so I am looking into a script I can simply have someone run in Management Studio that will do the trick.
Yes,
First create a Linked Server to other server, then you can access the target server by 4 part Names, for example:
Insert into Server2.Database2.dbo.MapTable1 select * from table1
p.s you can add linked server by sp_addLinkedServer

In SQL Server 2000 how to convert table to text file

In SQL Server 2000, I need to convert a table data (whole, not partial) to a text file (csv or tab).
How can I do this with a table (tblCustomer) which has name, address, phone number, for example?
I don't use SQL Server Management Studio. I have many groups of stored procedures running on daily basis and just want to write a stored procedure to add in to one of the groups.
Are you using SQL Server Management Studio?
If so, just right click on the database name, and choose tasks->export data from the context menu, then follow the wizard.
You you are using Management studio, you can try this:
In your SQL Server Management Studio, right-click on the database where the table is and select Tasks->Export Data. This will bring up
the SQL Server Import and Export Wizard, which is very much similar to
the DTS Import/Export utility of SQL Server 2000.
Select your table from the "Choose a Data Source" screen then click on Next.
In the "Choose a Destination", select "Flat File Destination" as your Destination and enter the File name.
Just click on Next after that and you should be ok already.
You can also export it to xml using a query and then, on your app, convert it do csv. Check this out: FOR XML
Or, as #Aaron said, use The BCP Utility
EDIT
As you said you want the query way, I would go for the For XML and them parse the result to a CSV format. AFAIK, SQL server does not have an way of doing what you want automatically, so you will have to make it yourself. Also, you can adapt this sample.
Here and here you can find some scripts that may help you.

Why SQL Server 2008 Management Studio doesn't have option "Open table"

I used to have option to open table in SQL Server 2005 Management Studio, but don't have that anymore in the 2008 version. Does anybody know why this option has been removed? And, if this feature is no longer available in the 2008 version, what is the best alternative to use?
Now it's Edit Top 200 rows.
They did this cause people were opening huge tables without thinking.
If you want to see 2000 rows, you can edit the select query when you right click -> pane -> SQL.
Then in your sql statement you will see Top(200). you just have to change to the number of rows you need.
The option is still there, it's just been renamed. I believe the old version used to attempt to get every single record in the table. The revised SSMS will, by default, get only the first 200.
Right-click a table and select Edit Top 200 Rows as shown below:
its good to change it like-
tools-> options ->SQL server object explorer -> commands --in this we can edit for whichever rows..