Use PHP to set column description in MSSQL
I'm working on a web app that is using PHP and MSSQL. One of my re开发者_如何转开发quirements is to use the field descriptions in MSSQL in part of the web app.
I know the Stored Proc. for adding descriptions in MSSQL is:
EXEC sp_addextendedproperty
@name = N'Description', @value = 'Description goes here',
@level0type = N'Schema', @level0name = 'schemaname',
@level1type = N'Table', @level1name = 'tablename',
@level2type = N'Column', @level2name = 'columname'
GO
I am having problems converting this into php, however.
I'm trying to use the mssql_init/bind/execute commands, but I keep getting an error that I am not sure how to troubleshoot.
PHP Code:
$query = mssql_init("sp_addextendedproperty",$dblink);
mssql_bind($query,"@name","N'Description'",SQLVARCHAR);
mssql_bind($query,"@value",$_POST['description'],SQLVARCHAR);
mssql_bind($query,"@level0type","N'Schema'",SQLVARCHAR);
mssql_bind($query,"@level0name","dbo",SQLVARCHAR);
mssql_bind($query,"@level1type","N'Table'",SQLVARCHAR);
mssql_bind($query,"@level1name",$_POST['tableselect'],SQLVARCHAR);
mssql_bind($query,"@level2type","N'Column'",SQLVARCHAR);
mssql_bind($query,"@level1name",$_POST['column_name'],SQLVARCHAR);
mssql_execute($query)
My error is:
An invalid parameter or option was specified for procedure 'sp_addextendedproperty'. (severity 16)
I don't know enough about stored procedures to fully troubleshoot this. Can somebody help me out?
Unless you've simply made a typo posting your sample code, you're using @level1name
twice. The second occurrence should be @level2name
instead.
精彩评论