background preloader

SQL Server

Facebook Twitter

Use the sqlcmd Utility. A.

Use the sqlcmd Utility

Running a script by using sqlcmd Start Notepad, and type the following Transact-SQL statements: USE AdventureWorks2012; SELECT TOP (3) BusinessEntityID, FirstName, LastName FROM Person.Person; Create a folder named MyFolder and then save the script as the file MyScript.sql in the folder C:\MyFolder. Sqlcmd -i C:\MyFolder\MyScript.sql -o C:\MyFolder\MyOutput.txt When you view the contents of MyOutput.txt in Notepad, you will see the following: Changed database context to 'AdventureWorks2012'. BusinessEntityID FirstName LastName 1 Syed Abbas 2 Catherine Abel 3 Kim Abercrombie (3 rows affected) B. In the following example, sqlcmd is used to connect to a server that has a blocking problem by using the dedicated administrator connection (DAC). C:\>sqlcmd -S ServerName -A 1> SELECT blocked FROM sys.dm_exec_requests WHERE blocked <> 0; Here is the result set. spid blocked (1 rows affected) Use sqlcmd to end the blocking process. C. IF OBJECT_ID ( ' dbo.ContactEmailAddress, 'P' ) IS NOT NULL SELECT EmailAddress.

Asp.net - SQL Server 2005 - How often should you rebuild Indexes. Local SQL Server 2008 ColdFusion Datasource. This morning I finished installing SQL Server 2008 on my local machine for development.

Local SQL Server 2008 ColdFusion Datasource

Having set up the database, I hit a small issue when trying to add the database as a datasource within the ColdFusion administrator, receiving the following error: Connection verification failed for data source: romixrDB java.sql.SQLNonTransientConnectionException: [Macromedia][SQLServer JDBC Driver]Error establishing socket to host and port: 127.0.0.1:1433. Reason: Connection refused: connect The root cause was that: java.sql.SQLNonTransientConnectionException: [Macromedia][SQLServer JDBC Driver]Error establishing socket to host and port: 127.0.0.1:1433. Reason: Connection refused: connect You can see a connection issue with the datasource, with a failure to connect on the socket using the localhost (127.0.0.1) and port number (1433). Expand the SQL Server Network Configuration menu item, and click on the Protocols option for the server, which will display the list of protocols in the main window: ALTER TABLE (Transact-SQL) Database_name Is the name of the database in which the table was created. schema_name Is the name of the schema to which the table belongs. table_name Is the name of the table to be altered.

ALTER TABLE (Transact-SQL)

Specifies that the named column is to be changed or altered. The modified column cannot be any one of the following: A column with a timestamp data type. The data type of columns included in an index cannot be changed unless the column is a varchar, nvarchar, or varbinary data type, and the new size is equal to or larger than the old size. A columns included in a primary key constraint, cannot be changed from NOT NULL to NULL. column_name Is the name of the column to be altered, added, or dropped. column_name can be a maximum of 128 characters. . [ type_schema_name. ] type_name Is the new data type for the altered column, or the data type for the added column. type_name cannot be specified for existing columns of partitioned tables. type_name can be any one of the following:

Bcp Utility. Data_file Is the full path of the data file.

bcp Utility

When data is bulk imported into SQL Server, the data file contains the data to be copied into the specified table or view. When data is bulk exported from SQL Server, the data file contains the data copied from the table or view. The path can have from 1 through 255 characters. The data file can contain a maximum of 263 - 1 rows. database_name Is the name of the database in which the specified table or view resides.

You can also explicitly specify the database name with d-. in data_file | outdata_file | queryoutdata_file | format nul Specifies the direction of the bulk copy, as follows: