SQL Server CREATE, ALTER, DROP Resource Guide

Problem

We want to create a resource guide to share with different teams to illustrate basic tasks like creating and modifying the most common objects, such as databases, tables, indexes, stored procedures, views, and functions. Sharing the information will ensure a consistent approach that teams can understand and apply to their situations. We cover things such CREATE TABLE in SQL, SQL CREATE VIEW and SQL CREATE DATABASE in this guide.

Solution

In this guide, we will walk through creating some of the most common objects needed in databases. We will break out each object and share insights on common features and options. This guide, coupled with MSSQLTips articles and Microsoft documentation, should help each team as they learn about creating the object, including caveats to consider. While not exhaustive to handle more advanced problems, this guide will give you the confidence to share with various teams to get them started.

The following sections are covered:

SQL Server Databases

Things to Think About

  • Database layout always requires at least one data file with the standard .mdf for the file name and one log file with .ldf as the standard.
  • Separating database files to different drives is a best practice and offers better performance when the drives are laid out correctly.
  • Consider replacing MAXSIZE = UNLIMITED with a size in MB that you want for a limit (KB and GB are also available)
  • Microsoft documentation on creating databases: Create a database.

Covered in this Section

  1. Create database.
  2. Add a file to the primary file group.
  3. Create a new filegroup and add a file to it.
  4. Close all connections and drop a database.

1. Create a Database

/** MSSQLTips.com - #1 - Create a database **/
USE master;
GO
CREATE DATABASE [DATABASE_NAME]
on
PRIMARY (NAME='PRIMARY', FILENAME='C:\SQL2022\SQL_Data\database_name.mdf', SIZE = 1024MB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024MB),
/**Optional additional file group for indexes, large tables, etc. ****/
(NAME='Filegroup2', FILENAME='C:\SQL2022\SQL_Data\filegroup2.ndf', SIZE = 1024MB , MAXSIZE = UNLIMITED , FILEGROWTH = 1024MB)
LOG ON (NAME='database_name_log', FILENAME='C:\SQL2022\SQL_Data\database_name.ldf');

2. Add a File to the Primary File Group

/** MSSQLTips.com - #2 - CAN ALSO: add a file to the primary file group **/
ALTER DATABASE [DATABASE_NAME]
ADD FILE 
(
    NAME = SQLData2,
    FILENAME = 'C:\SQL2022\SQL_Data\database_name_SQLData2.ndf',
    SIZE = 1024MB,
    MAXSIZE = 1024MB,
    FILEGROWTH = 1024MB
);

3. Create a New File Group and Add a File to It

/** MSSQLTips.com - #3 - CAN ALSO: create a new file group and add a file to it **/
USE master
GO
ALTER DATABASE [DATABASE_NAME]
ADD FILEGROUP FileGroupName;
GO
ALTER DATABASE [DATABASE_NAME]
ADD FILE
(
    NAME = SQLData3,
    FILENAME = 'C:\SQL2022\SQL_Data\database_name_SQLData3.ndf',
    SIZE = 1024MB,
    MAXSIZE = 1024MB,
    FILEGROWTH = 1024MB
)
TO FILEGROUP FileGroupName;
GO

4. Drop the Database

/** MSSQLTips.com - #4 - CAN ALSO: Drop the database and close all connections to it **/
use master
GO
ALTER DATABASE [DATABASE_NAME] SET  SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO
DROP DATABASE [DATABASE_NAME];
GO

SQL Server Tables

Things to Think About

  • If not specified, the default is to create on the DBO schema.
  • If unsure, use nvarchar datatype over varchar.
  • Avoid using UNIQUEIDENTIFIER for the primary key unless there’s a strong use case.
  • Read the Microsoft documentation on table creation (Create tables (Database Engine))and carefully review data types, too.

Covered in this section

  1. Create a table.
  2. Create a table on a different file group.
  3. Create a table with a constraint.
  4. Add a constraint to an existing table.
  5. Add a column to an existing table.
  6. Drop a column.
  7. Change the datatype of an existing column.
  8. Add a foreign key.
  9. Drop a table.

1. Create a Table

/*** MSSQLTips.com - #1 - Create a table ***/
CREATE TABLE DBO.TableName (
   KeyID bigint IDENTITY PRIMARY KEY, /* Primary key*/
   ColumnOne nvarchar(500), /* nvarchar datatype supports a wider variety of characters at the expense of more storage */
   ColumnTwo varchar(500), /* varchar uses less space but difficult to change later */
   ColumnThree datetime2 /* Used for tracking dates */
   ) on [PRIMARY] ;/* [ left and right ] brackets required - defaults to the primary filegroup when omitted*/

2. Create a Table on a Different File Group

/** MSSQLTips.com - #2 CAN ALSO: create a table on a different file group **/
CREATE TABLE DBO.TableName (
   KeyID bigint IDENTITY, 
   ColumnOne nvarchar(500),
   ColumnTwo varchar(500), 
   ColumnThree datetime2 
   ) on [otherFileGroup] ;/* file group and file must already exist */

3. Create a Table with a Constraint

/** MSSQLTips.com - #3 CAN ALSO: create a table with a constraint on a column which enforces a business requirement */
CREATE TABLE DBO.TableName (
   KeyID bigint IDENTITY, 
   ColumnOne nvarchar(500) CONSTRAINT CHK_value CHECK (ColumnOne <> 'BadValue'), /* Will not accept BadValue*/
   ColumnTwo varchar(500), 
   ColumnThree datetime2 
   ) on [PRIMARY];

4. Add a Constraint After a Table is Created

/** MSSQLTips.com - #4 CAN ALSO: add a constraint after the table is created.  Replace CONSTRAINT_NAME with yours such as "CHK_ColValue"  */
ALTER TABLE DBO.TableName
ADD CONSTRAINT CONSTRAINT_NAME  CHECK (ColumnnName <> 'BadValue');

5. Add a Column After the Table has been Created

/** MSSQLTips.com - #5 CAN ALSO: add a column after the table is created **/
ALTER TABLE DBO.TableName 
ADD NewColumnName datetime2; /* or other data type */

6. Drop a Column from a Table

/** MSSQLTips.com - #6 CAN ALSO: drop a column from an existing table **/
ALTER TABLE DBO.TableName
DROP COLUMN ColumnName;

7. Change the Data Type of an Existing Column

/** MSSQLTips.com - #7 CAN ALSO: change the data type of an existing column **/
ALTER TABLE DBO.TableName 
ALTER COLUMN ColumnName nvarchar(500) ;/* New data type must be compatible with the existing data */

8. Add a Foreign Key to Point at Another Table’s Primary Key

/** MSSQLTips.com - #8 CAN ALSO: Add foreign key to another table's primary key*/
ALTER TABLE TableName
ADD CONSTRAINT FOREIGN_KEY_NAME FOREIGN KEY (ColumnNameOfPrimaryKey) /*This table's primary key*/
REFERENCES TableName(ColumnNameOfPrimaryKey) /*That table's primary key*/;

9. Drop a Table

/** MSSQLTips.com - #9 CAN ALSO: Drop a table **/
DROP TABLE DBO.TableName

SQL Server Views

Things to Think About

  • Use SCHEMABINDING. This prevents underlying table changes.
  • Read the Microsoft documentation (CREATE VIEW (Transact-SQL)) for a full list of caveats and restrictions.
  • Views can be indexed, but only if there’s an existing clustered index on the view.

Covered in this Section

  1. Build Out Test Tables
  2. Create a View
  3. Create a View that Does Not Allow Changes Through the View, Such as Inserts, Updates, and Deletes
  4. Create a View that Prevents Changes to the Underlying Table
  5. Modify a View By Adding a Column
  6. Remove a Column from a View
  7. Create a Non-clustered Index on a View
  8. Create a Clustered Index on a View

0. Build Out Test Tables

/**  MSSQLTips.com   Build out test tables **/
USE DBNAME_TO_CREATE_TABLE;
GO
CREATE TABLE DBO.TBLVWTEST 
(PKID INT IDENTITY PRIMARY KEY,
Item nvarchar(200),
ItemCategory nvarchar(200),
ItemID int
)
 
INSERT INTO DBO.TBLVWTEST
values
('Shirt', 'Basketball', 1),
('Shirt', 'Baseball', 2),
('Shirt', 'Football', 3)
 
CREATE TABLE DBO.TBLVWTEST2 
(PKID INT IDENTITY PRIMARY KEY,
Size nvarchar(200),
StockItem int,
InStock int
)
INSERT INTO DBO.TBLVWTEST2
values
('Small', 1, 10),
('Medium', 1, 11),
('Large', 1, 12 ),
('XLARGE', 1, 55),
('Small', 2, 1),
('Medium', 2, 43),
('Large', 2, 14 ),
('XLARGE', 2, 19),
('Small', 3, 81),
('Medium', 3, 30),
('Large', 3, 15 ),
('XLARGE', 3, 61)

1. Create a View

/*** MSSQLTips.com #1  Create view from a select statement ***/
CREATE VIEW VW_VWTEST1 as
SELECT Item, ItemCategory, ItemID
from DBO.TBLVWTEST

2. Create a View that Does Not Allow Changes Through the View, Such as Inserts, Updates, and Deletes

/*** MSSQLTips.com #2  CAN ALSO: Make a view read only with a trigger ***/
CREATE TRIGGER TR_READONLY_VW_VWTEST1
ON VW_VWTEST1
INSTEAD OF INSERT, UPDATE, DELETE
AS
BEGIN
    RAISERROR('The view is read only.', 16, 1);
    ROLLBACK TRANSACTION;
END;

3. Create a View that Prevents Changes to the Underlying Table

/*** MSSQLTips.com #3  CAN ALSO: Create a view that prevents the underlying table from changing ***/
CREATE VIEW DBO.VW_VWTEST2 WITH SCHEMABINDING
as
SELECT Item, ItemCategory, ItemID
from DBO.TBLVWTEST

4. Modify a View By Adding a Column

/*** MSSQLTips.com #4  CAN ALSO: Modify a view to add a column ***/
ALTER VIEW DBO.VW_VWTEST1 as
SELECT Item, ItemCategory, ItemID, PKID
from DBO.TBLVWTEST

5. Remove a Column from a View

/*** MSSQLTips.com #5  CAN ALSO: Modify a view to remove a column ***/
ALTER VIEW DBO.VW_VWTEST1 as
SELECT Item, ItemCategory
from DBO.TBLVWTEST

6. Create a Non-clustered Index on a View

/*** MSSQLTips.com #6  CAN ALSO: Create a non-clustered index on a view that already has a clustered index ***/
/** non-clustered indexes require a clustered index on the view **/
CREATE NONCLUSTERED INDEX IDX_VWTEST_COLS ON
DBO.TBLVWTEST (Item, ItemCategory)

7. Create a Clustered Index on a View

/*** MSSQLTips.com #7 CAN ALSO: Create a clustered index on a view
/******
Some caveats to the clustered index.
1.  The index must be detereministic - in other words, if you have a where clause, group by, etc., the results must be consistent every time with the same set of values
2.  View created by the owner of the table
3.  Full list of requirements here:
   https://learn.microsoft.com/en-us/sql/relational-databases/views/create-indexed-views?view=sql-server-ver16
******/
***/
 
/* Create a test table with some data */
CREATE TABLE DBO.TBLVWTEST3 
(OwnerName nvarchar(255),
OwnerID int,
OwnerState nvarchar(2),
CustCategory int)
INSERT INTO DBO.TBLVWTEST3
VALUES 
('Super Company, Inc',1,'MA',127),
('A better rootbeer, Inc',2,'VA',14),
('Swiss Cheese insurance co',3,'CA',19),
('Possums, Inc',4,'FL',14),
('A better Soda Co.',5,'VA',14),
('Average rootbeer, Inc',6,'CT',14),
('Cheddar Cheese Factory',7, 'IA', 20)
 
CREATE UNIQUE CLUSTERED INDEX IDX_V1 ON DBO.TBLVWTEST3 (
    OwnerID, OwnerName
);

SQL Server Stored Procedures

Things to Think About

  • Create stored procedures for tasks that are used over and over
  • Make your stored procedures dynamic by using parameters
  • Include error handling in your stored procedures
  • Make sure you comment the code in the stored procedures for future reference

Covered in this Section

  1. Build Out Test Table
  2. Create a Stored Procedure that Returns Values from a Select Statement
  3. Create a Stored Procedure with Defaults
  4. Stored Procedure that Inserts by a Parameter
  5. Find a Value Based on a Parameter
  6. Accept Multiple Parameters
  7. Return a Value as an Output Parameter
  8. Drop a Stored Procedure

0. Build Out Test Table

/*** MSSQLTips.com - #0 - Build out a test table to work with ***/
USE DBNAME_TO_CREATE_TABLE;
GO
CREATE TABLE DBO.SPROCTEST 
(PKID INT IDENTITY PRIMARY KEY,
ColumnOne nvarchar(200),
ColumnTwo nvarchar(200),
ColumnThree int,
ColumnFour int
)
INSERT INTO DBO.SPROCTEST
values
('Shirt', 'Basketball', 1,77),
('Sock', 'Baseball', 43,1),
('Hat', 'Soccer ball', 5,7),
('Necklace', 'Golf ball', 84,255),
('Shirt', 'Soccer ball', 3,20),
('Shoe', 'Basketball', 13, 31),
('Sweater', 'Widget', 9,5)

1. Create a Stored Procedure that Returns Values from a Select Statement

/*** MSSQLTips.com - #1  Create a procedure that returns values from a select statement */
CREATE or ALTER PROCEDURE USP_GETPRODUCTDESCRIPTIONS
AS 
SET NOCOUNT ON
SELECT ColumnOne, ColumnTwo from DBO.SPROCTEST;
GO
EXEC USP_GETPRODUCTDESCRIPTIONS

2. Create a Stored Procedure with Defaults

/** MSSQLTips.com - #2 CAN ALSO: accept defaults when param not provided*/
CREATE or ALTER PROCEDURE USP_GETAPRODUCTDESCRIPTION
(@findThis nvarchar(200) = 'Hat')
AS 
SET NOCOUNT ON
SELECT columnOne, ColumnTwo from DBO.SPROCTEST
where columnOne = @findThis;
GO
/* Test it */ 
EXEC USP_GETAPRODUCTDESCRIPTION;
/* Or with a param*/
EXEC USP_GETAPRODUCTDESCRIPTION @findThis = 'Belt'; 

3. Stored Procedure that Inserts by a Parameter

/** MSSQLTips.com - #3 CAN ALSO: insert data into a table by passing in params  */
CREATE OR ALTER PROCEDURE USP_INSERTINTOSPROCTEST
@ColumnOne nvarchar(200), @ColumnTwo nvarchar(200), @ColumnThree int, @ColumnFour int
AS
SET NOCOUNT ON
INSERT INTO DBO.SPROCTEST 
(ColumnOne, ColumnTwo, ColumnThree, ColumnFour)
VALUES
(@ColumnOne, @ColumnTwo, @ColumnThree, @ColumnFour);
/* Test it: @variableName added in this example*/
exec USP_INSERTINTOSPROCTEST @ColumnOne = 'Belt', @ColumnTwo = 'Baseball', @ColumnThree = 8, @ColumnFour = 91;

4. Find a Value Based on a Parameter

/** MSSQLTips.com - #4 CAN ALSO: Look for something based on an input parameter ***/
CREATE or ALTER PROCEDURE USP_GETAPRODUCTDESCRIPTION
(@findThis nvarchar(200))
AS 
SET NOCOUNT ON
SELECT columnOne, ColumnTwo from DBO.SPROCTEST
where columnOne = @findThis;
GO
/* Test it: @variable name omitted but SQL Server knows what we mean */ 
EXEC USP_GETAPRODUCTDESCRIPTION 'Hat';

5. Accept Multiple Parameters

/** MSSQLTips.com - #5 CAN ALSO: accept multiple parameters **/
CREATE OR ALTER PROCEDURE USP_GETAPRODUCTDESCRIPTIONWITHPARAM
(@findThis nvarchar(200), @withThis nvarchar(200))
AS 
SET NOCOUNT ON
SELECT ColumnOne, ColumnTwo, ColumnThree, ColumnFour from DBO.SPROCTEST
where columnOne = @findThis and columnTwo = @withThis
GO
/* Test it with multiple values */
EXEC USP_GETAPRODUCTDESCRIPTIONWITHPARAM 'Shoe', 'Basketball';

6. Return a Value as an Output Parameter

/** MSSQLTips.com - #6 CAN ALSO: return a value as an output parameter to be used */
CREATE OR ALTER PROCEDURE USP_RETURNAVALUE
(@findThis nvarchar(200), @withThis nvarchar(200), @outputThis int OUTPUT)
AS 
SET NOCOUNT ON
SELECT @outputThis = ColumnThree from DBO.SPROCTEST
where columnOne = @findThis and columnTwo = @withThis;
RETURN @outputThis;
GO
 
/* Test it: Must declare the variable to receive the output */
declare @grabTheValue int
exec usp_returnAValue 'Shoe', 'Basketball', @outputThis = @grabTheValue OUTPUT;
select @grabTheValue as ValueOutput/* Do something with the value received */

7. Drop a Stored Procedure

/** MSSQLTips.com - #7 CAN ALSO: drop a stored procedure **/
DROP PROCEDURE USP_RETURNAVALUE; 

SQL Server Indexes

Things to Think About

  • The right indexes can drastically improve performance
  • Only create indexes where they are helpful
  • Don’t over index your tables
  • Try to not use to many include columns in your indexes
  • Ensure your tables have a clustered index

Covered in this Section

  1. Build Out a Test Table
  2. Create a Clustered Index
  3. Create a Non-clustered Index
  4. Non-clustered Index on Multiple Columns
  5. Unique Index
  6. Index with Included Columns
  7. Filtered Index
  8. Add Columns to an Index
  9. Rebuild an Index
  10. Reorganize an Index
  11. Drop an Index

0. Build Out a Test Table

/*** MSSQLTips.com  Create a table to test with ***/
USE DBNAME_TO_CREATE_TABLE;
GO
CREATE TABLE DBO.INDEXTEST 
(PKID INT IDENTITY,
ColumnOne nvarchar(200),
ColumnTwo nvarchar(200),
ColumnThree int,
ColumnFour int
)
INSERT INTO DBO.INDEXTEST
values
('Shirt', 'Basketball', 1,77),
('Sock', 'Baseball', 43,1),
('Hat', 'Soccer ball', 5,7),
('Necklace', 'Golf ball', 84,255),
('Shirt', 'Soccer ball', 3,20),
('Shoe', 'Basketball', 13, 31),
('Sweater', 'Widget', 9,5)

1. Create a Clustered Index

/** MSSQLTips.com - #1 - Create a clustered index **/
CREATE CLUSTERED INDEX IX_INDEXTEST_PKID ON DBO.INDEXTEST (PKID);
GO

2. Create a Non-clustered Index

/** MSSQLTips.com - #2 - CAN ALSO: Create a non-clustered index **/
CREATE INDEX IX_INDEXTEST_ColOne ON DBO.INDEXTEST (ColumnOne);

3. Non-clustered Index on Multiple Columns

/** MSSQLTips.com - #3 - CAN ALSO: Create a non-clustered index on multiple columns **/
CREATE INDEX IX_INDEXTEST_ColOneColTwo ON DBO.INDEXTEST (ColumnOne, ColumnTwo);

4. Unique Index

/** MSSQLTips.com - #4 - CAN ALSO: Create a unique index which forces uniqueness on that column **/
CREATE UNIQUE INDEX IX_INDEXTEST_ColOne ON DBO.INDEXTEST (ColumnOne);

5. Index with Included Columns

/** MSSQLTips.com - #5 - CAN ALSO: Create an index with included columns **/
CREATE INDEX IX_INDEXTEST_ColOneInclColTwo ON DBO.INDEXTEST (ColumnOne) INCLUDE (ColumnTwo);

6. Filtered Index

/** MSSQLTips.com - #6 - CAN ALSO: Create a filtered index **/
CREATE INDEX IX_INDEXTEST_ColOneFiltColTwo ON DBO.INDEXTEST (ColumnOne, ColumnTwo)
WHERE ColumnTwo = 'Basketball';

7. Add Columns to an Index

/** MSSQLTips.com - #7 - CAN ALSO: Add columns to an index **/
CREATE INDEX IX_INDEXTEST_ColOne ON DBO.INDEXTEST (ColumnOne, ColumnTwo)
    WITH (DROP_EXISTING = ON);

8. Rebuild an Index

/** MSSQLTips.com - #8 - CAN ALSO: Rebuild an index to reduce fragmentation  **/
ALTER INDEX IX_INDEXTEST_PKID ON DBO.INDEXTEST REBUILD
   WITH (FILLFACTOR= 100, SORT_IN_TEMPDB=ON);

9. Reorganize an Index

/** MSSQLTips.com - #9 - CAN ALSO: Reorganize index to reduce leaf level fragmentation **/ 
ALTER INDEX IX_INDEXTEST_PKID ON DBO.INDEXTEST REORGANIZE

10. Drop an Index

/** MSSQLTips.com - #10 - CAN ALSO: Drop an index **/
DROP INDEX IX_INDEXTEST_PKID ON DBO.INDEXTEST

SQL Server Functions

Things to Think About

  • Create functions for tasks that are used over and over
  • Include error handling in your functions
  • Make sure you comment the code in the functions for future reference

Covered in this Section

  1. Build Out Test Tables
  2. Create a Function that Returns a Single Value (Scalar Valued Function)
  3. Function Usage in a Select Statement to Return a Value
  4. Pass in a Parameter to a SQL Function and Return a Single Value
  5. Create a Table Value Function Returning a Table as a Result Set
  6. Join a Table and a Table Value Function for a Result Set

0. Build Out Test Tables

/** MSSQLTips.com - #0 Build out test tables **/
CREATE TABLE DBO.VENDORS 
(PKID INT IDENTITY PRIMARY KEY,
VendorName NVARCHAR(200),
VendorCity NVARCHAR(200),
Specialty NVARCHAR(200)
)
INSERT INTO DBO.VENDORS
(VendorName, VendorCity, Specialty)
values
('Rockingham cars', 'Rockingham', 'Pickup'),
('Discount Supplies', 'New York', 'Sedan'),
('Green Tech Elec Cars', 'Madison', 'Pickup'),
('BayView Cars', 'Boston', 'Pickup'),
('Sunrise Auto', 'Los Angeles', 'Big Sedan'),
('Premier Autos', 'Cheboygan', 'Big Sedan'),
('Galactic Used Cars', 'Philadelphia', 'Electric Cars')
   
CREATE TABLE DBO.CARPRICE
(CarType NVARCHAR(200),
CarPrice DECIMAL(12,6))
 
INSERT INTO DBO.CARPRICE
VALUES
('Pickup', 27395.11),
('Sedan', 24112.89),
('Big Sedan', 26001.70),
('ElectricCar', 21789.50),
('EconomyCar', 20911.14),
('Pickup4dr', 37789.50)

1. Create a Function that Returns a Single Value (Scalar Valued Function)

/** MSSQLTips.com - #1 - Create a function that returns a single value (Scalar valued function) **/
CREATE FUNCTION FNGETAVGPRICE()
   RETURNS DECIMAL
BEGIN
   RETURN (SELECT AVG(CarPrice) from DBO.CARPRICE)
END
GO
SELECT DBO.FNGETAVGPRICE() as AVGPRICE

2. Function Usage in a Select Statement to Return a Value

/** MSSQLTIPS.com - #2 - CAN ALSO: Use it in a select statement to return a value **/
SELECT CarType, CarPrice, DBO.FNGETAVGPRICE() AS AvgOfAllCars 
FROM DBO.CARPRICE
WHERE CarType = 'EconomyCar'

3. Pass in a Parameter to a SQL Function and Return a Single Value

/** MSSQLTIPS.com - #3 - CAN ALSO: Pass in a parameter and return a single value **/
CREATE FUNCTION FNGETSALEPRICE(@carType NVARCHAR(200))
   RETURNS DECIMAL
BEGIN
  RETURN (SELECT CarPrice from DBO.FUNCTIONTEST where CarType = @carType )
END;
GO
SELECT dbo.FNGETSALEPRICE('Pickup4dr') AS PRICE

4. Create a Table Value Function Returning a Table as a Result Set

/** MSSQLTips.com - #4 CAN ALSO:  Table Value function - return a result as a table**/
CREATE FUNCTION dbo.GetAllVendors()
RETURNS TABLE
AS
RETURN
(
    SELECT VendorName, VendorCity, Specialty
    FROM DBO.VENDORS
);
GO
select * from GetAllVendors()

5. Join a Table and a Table Value Function for a Result Set

/** MSSQLTips.com - #5 CAN ALSO: Table Value function - join a table and a table value function result set **/
SELECT c.CarPrice, g.VendorName, g.VendorCity, g.Specialty
FROM DBO.CARPRICE c 
INNER JOIN GetAllVendors() g
   ON c.CarType = g.Specialty

Next Steps

Leave a Reply

Your email address will not be published. Required fields are marked *