Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

How to Get Default Value of a Data Type in SQL Query.

$
0
0

Hi all,

I am creating a procedure which will take input the table name and Column Name.

In the Output i would like to have the data type and default value of that data type which will be used by a another procedure to blank the selected column in the database.

I tried with SET NULL on the column but as the database is of navision the table have property set to NOT NULL.

Here is what i have done till now.

Create Procedure Get_Column_type
@parm_table_name nvarchar(200),
@parm_column_name nvarchar(20),
@parm_result nvarchar(20)OUTPUT
AS
BEGIN 
select @parm_result = 
DATA_TYPE from INFORMATION_SCHEMA.COLUMNS IC
where TABLE_NAME = '[' + @parm_table_name +']' and COLUMN_NAME = '[' + @parm_column_name + ']'
END
GO

Now instead on write a case statement for so many data types in SQL, i was thinking is it possible someway that above procedure also returns the default value which i can set in another procedure.

Let me know if its possible or not? Thanks in advance.



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>